Home Tutorial Php Phpgd PHP GD Image Resize

 
 

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.

<?php

$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:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.