note 14219 deleted from function.imagecopyresized by sander
| From: | sander@php.net | Date: | Sat, 06 Apr 2002 19:20:46 +0000 |
| Subject: | note 14219 deleted from function.imagecopyresized by sander | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-28771@lists.php.net to get a copy of this message | ||
I've been trying to get resizing for a thumbnail figured out and I've either got a clot or
I've been at it too long.
Assuming a GIF on disk, I want to stream it the browser. Here is the code I'm using that DOES
NOT work. I get a traditional broken link and a place hold the size of the original on-disk image.
My thumbnails need to be a maximum x or y dimension of $thumnailsize, say 100 pixels, yet scaled to
fit that box proportionally.
$img = ImageCreateFromGIF($path);
if(imagesx($img) > imagesy($img)) {
$sf = double($thumbnailsize) / imagesx($img);
} else {
$sf = double($thumbnailsize) / imagesy($img);
}
$neww = imagesx * $sf;
$newh = imagesy * $sf;
$tn = ImageCreate($neww, $newh);
ImageCopyResized($tn, $img, 0,0,0,0, $neww, $newh,
imagesx($img), imagesy($img));
Header("Content-Type: image/gif");
ImageGif($tn);
ImageDestroy($tn);
ImageDestroy($img);
Running PHP4.0.5 and GD 1.8.x with GIF patch