我已经编写了一些代码来调整图像大小(遵循PHP手册),但是我无法获取要显示的图像。我知道图像数据存在,因为我可以看到它时,我回声$拇指,但我似乎无法得到实际的图像显示。header(content-type:image/jpeg)not working
这是我使用的代码:
$row = mysql_fetch_array($result);
$image = $row["image"];
echo $image;
echo $row["name"];
list($width, $height) = getimagesize($image);
$newwidth = $width * 0.1;
$newheight = $height * 0.1;
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($image);
imagecopyresized($thumb, $source, 0,0,0,0, $newwidth, $newheight, $width, $height);
header('Content-Length: '.strlen($thumb), true);
header("Content-type: image/jpeg");
echo imagejpeg($thumb);
感谢您的帮助
卸下'echo'。 'imagejpeg($ thumb)'就足够了(如果$ thumb是一个合适的图片资源) –
看看你实际发送出去,通过保存到文件或使用网络嗅探器。当某些东西不起作用时,总是精确地看看实际产生的东西,不要停留在元层次上(“不起作用”)。发送的内容是否是jpeg?不,你可以看到,如果你看内容。 – arkascha
试图消除回声,但我只是得到的数据不是实际的图像,但无论如何感谢。 – Sarita