Home Tutorial Php Phpgd PHP GD Image Resize


Share on Google+Share on Google+
PHP GD Image Resize
Posted on: November 11, 2009 at 12:00 AM
This example shows how to Images resize and save image in php gd.


$file = 'images.jpg';

$save = 'new.jpg';

list($width, $height) = getimagesize($file) ;

$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);

echo("Image created and saved successfully.");


After running the program you will get the following output


Related Tags for PHP GD Image Resize:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 11, 2009

Recommend the tutorial

Advertisements Advertisements