0 && $h != $height) || ($w > 0 && $w != $width)) { // calc proportional dimension based upon what's given if ($h > 0) $w = round((0.5 + ($h * $width)) / $height); else $h = round((0.5 + ($w * $height)) / $width); // resize $destImg = imagecreatetruecolor($w, $h); imagecopyresized($destImg,$srcImg,0,0,0,0,$w,$h,$width,$height); imagejpeg($destImg); } else imagejpeg($srcImg); exit; ?>