Resize Image

Get Size

list($src_w, $src_h) = getimagesize($filename);

Create png from path

$src_image = @imagecreatefrompng($filename);

Create jpg from path

$src_image = imagecreatefromjpeg($filename);

Create png from with, height

$dst_w = 200;
$dst_h = 180;
$dst_image = imagecreatetruecolor($dst_w, $dst_h);
imageAlphaBlending($dst_image, false);
imagesavealpha($dst_image, true);

Create jpg from with, height

$dst_w = 200;
$dst_h = 180;
$dst_image = imagecreatetruecolor($dst_w, $dst_h);

Save png

imagepng($dst_image, $dir_dst. DIRECTORY_SEPARATOR . $filename);

Save jpg

imagejpeg($dst_image, $dir_dst. DIRECTORY_SEPARATOR . $filename);

Destroy

imagedestroy($dst_image);
imageDestroy($src_image);