如果图像尺寸超过 604x453,我想这样做,然后将其调整为 604x453。
我已经做到了这一点:
$org_name = stripslashes($_FILES[$upload_name]['name']);
$file_size = $_FILES[$upload_name]['size'];
$file_temp = $_FILES[$upload_name]['tmp_name'];
$file_type = $_FILES[$upload_name]["type"];
$file_err = $_FILES[$upload_name]['error'];
list($width, $height, $type, $attr) = $imageSizeInfo;
$move_me = "images/users/status/".$org_name;
if(move_uploaded_file($file_temp, $move_me)) {
echo "{";
echo "msg: '".$org_name."'";
echo "}";
}
if($width > 604 && $height > 453) {
$jpeg_quality = 90;
$src = "images/users/status/".$org_name;
$ext= pathinfo($src, PATHINFO_EXTENSION);
$targ_h = 453;
$targ_w = 604;
$path_thumbs = "images/users/status/";
$thumb_path = $path_thumbs . '/' . $newfilename;
if($ext == "jpg" OR $ext == "jpeg" OR $ext == "JPG"){
$img_r = imagecreatefromjpeg($src);
}elseif($ext == "png" OR $ext == "PNG"){
$img_r = imagecreatefrompng($src);
}elseif($ext == "gif" OR $ext == "GIF"){
$img_r = imagecreatefromgif($src);
}
$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
imagejpeg($dst_r,$thumb_path,$jpeg_quality);
unlink($move_me);
}
因此,首先它上传具有原始尺寸和所有内容的文件,然后在检查尺寸然后调整其大小,并取消链接(删除)原始文件..
现在我不知道是什么,但不知何故在调整大小过程中它出错了,我只得到一个尺寸为 604x453 的黑色方块作为输出..
我错过了什么,我该如何解决?