function f_resizeMaxHeight($file, $height) { $imSrc = imagecreatefromjpeg($file); $w = imagesx($imSrc); $h = imagesy($imSrc); if($h>$height) { $width = ($w/$h)*$height; $imTrg = imageCreateTrueColor($width, $height); imagecopyresized($imTrg, $imSrc, 0, 0, 0, 0, $width, $height, $w, $h); imagedestroy($imSrc); imagejpeg($imTrg, $file, 95); imagedestroy($imTrg); } else { imagedestroy($imSrc); } }