Re: Generate Thumbnail gif's
| From: | Leif K-Brooks | Date: | Wed, 29 Oct 2003 06:10:33 +0000 |
| Subject: | Re: Generate Thumbnail gif's | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167969@lists.php.net to get a copy of this message | ||
Vijaya_Manda wrote:
Is there any pre-written code available on the net to generate thumbnail images for a picture. I mean I send the path of the image and my PHP Script should be able to generate a gif file of size 100x71 or something like that. Images will look stretched if you do that, but here are two functions to resize an image with a new width or height proportional to its current size. Pass them GD image resources created with imagecreatefrompng() and friends.function imageresizeheight($img, $newheight) { $oldheight = imagesy($img); $oldwidth = imagesx($img); $newwidth = $oldwidth * ($newheight / $oldheight); $newimg = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($newimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $oldwidth, $oldheight); return $newimg; } function imageresizewidth($img, $newwidth) { $oldheight = imagesy($img); $oldwidth = imagesx($img); $newheight = $oldheight * ($newwidth / $oldwidth); $newimg = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($newimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $oldwidth, $oldheight); return $newimg; } -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.