PHP GD Image Resize


 

PHP GD Image Resize

This example shows how to Images resize and save image in php gd.

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

Ads