header(Content-type: image/jpeg) not working
I have written some code to resize an image (followed PHP manual) but I
cannot get the image to display. I know the image data exists as I can see
it when I echo the $thumb but I can't seem to get the actual image to
display.
This is the code I have used:
$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);
Thank you for any help
Monday, August 19, 2013
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment