Zmena veľkosti obrázku so zachovaným pomerom strán.

<?
//define path to image
$image="path/image.jpg";    
$imgSrc="path/newimage.php";
 
$size=getImageSize($image);
 
//define $w - width !!!OR!!! $h - height
//another property is counted
if($h){    $w=$size[0]/($size[1]/$h); }
else{    $h=$size[1]/($size[0]/$w); }
 
header("Content-type: image/jpeg");
$dst_img=ImageCreatetruecolor($w,$h);        
$src_img=ImageCreateFromjpeg($imgSrc);
ImageCopyResized($dst_img,$src_img,0,0,0,0,$w,$h,ImageSX($src_img),ImageSY($src_img));
ImageJpeg($dst_img);
?>