Splash Posted July 26, 2007 Share Posted July 26, 2007 Hi all I'm trying to set up a script that will generate thumbnails for an image gallery using GD Library. I'm using the following script, which resizes the image to 100px x 100px. It's working fine however I has hoping someone could help me edit it so that it shrinks the image by 50% then crops the thumbnail from the center. <?php //Input file $file = 'image.jpg'; //Output file $save = 'new.jpg'; //Get image dimensions list($width, $height) = getimagesize($file) ; //Set new Dimensions $modwidth = 100; $modheight = 100; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100); ?> Thanks a lot Link to comment https://forums.phpfreaks.com/topic/61856-gd-library-cropping/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.