Re: problems with thumbnail image

From: Date: Fri, 02 Mar 2007 16:29:43 +0000
Subject: Re: problems with thumbnail image
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-249722@lists.php.net to get a copy of this message
> I have used this method for generating the thumbnail images. I avoided > creating the thumbnails and saving to the disk as the images change very > frequently. > > Thank you so much for helping me with this one:)) > > regards > Punit Neb The problem is that your function generates thumbnail and then tries to return the binary image within the html document. Html contains *links* to images, not the images themselves. So you need to do something like this: <img src="create_thumbnail.php?filename=<? echo $photo_img_name; ?>"> Then you create_thumbnail.php can return the binary image: <? // be sure to validate the user supplied parameter! $photo_img_name = $_REQUEST['filename']; $percent = 0.5; list($width, $height) = getimagesize($photo_img_name); $newwidth = $width * $percent; $newheight = $height * $percent; $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefrompng($photo_img_name); imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // or whatever the correct mime/type is header("Content-type: image/png"); echo imagepng($thumb); }

« previous php.general (#249722) next »