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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to