我想调整我的图片大小,使其不超过 500 像素。纵横比必须相同。我的图像 (960x960) 没有任何变化。
这是我的代码:
public static function resizeImage($imagename) {
list($width, $height) = getimagesize($imagename);
if($width < 500)
return $imagename;
$ratio = $width / $height;
$new_width = 500;
$new_height = $new_width / $ratio;
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($imagename);
imagecopyresampled ($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
return $imagename;
}
这是 imagecopyresampled 的输入
Resource id #25|Resource id #27|0|0|0|0|500|500|960|960|