note 14219 added to function.imagecopyresized.php

From: Date: Mon, 23 Jul 2001 01:30:01 +0000
Subject: note 14219 added to function.imagecopyresized.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15687@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 http://www.php.net/manual/en/function.imagecopyresized.php

« previous php.notes (#15687) next »