$maxWidth) { $h = intval($h*$maxWidth/$w); $w = $maxWidth; } if($h > $maxHeight) { $w = intval($w*$maxHeight/$h); $h = $maxHeight; } //echo $w.",".$h;exit; $img2 = imagecreatetruecolor($w, $h); imagecopyresampled($img2, $img, 0, 0, 0, 0, $w, $h, $w_o, $h_o); if($destPath) { imagejpeg($img2, $destPath, 80); } else { header("Content-Type:image/jpeg"); imagejpeg($img2, '', 80); } imagedestroy($img2); imagedestroy($img); } //resizeImg("1.jpg", 300, 300);