我曾经以百分比的方式做到这一点虽然现在我希望用像素来做这件事,虽然在试用之后,这些图像似乎没有调整大小?我不确定为什么?
$get_resize_width = '225';
$get_resize_height = '150';
$info = getimagesize($file);
list($width, $height) = getimagesize($file);
$new_width = $get_resize_width;
$new_height = $get_resize_height;
if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($file);
elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($file);
elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($file);
$image = imagecreatetruecolor($new_width, $new_height);
$photo = imagecreatefromjpeg($file);
imagecopyresampled($image, $photo, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image, $newfile, $img_quality);
$origional_image = $file;
$compressed_image = $newfile;
我尝试将px
添加到变量的末尾,虽然这似乎没有什么区别?