输入类型文件-上传图片
$arr = $_FILES['inpfile'];
$filename = $arr['name'];
$tempname = $arr['tmp_name'];
$arr = getimagesize($tempname);
$origw = $arr[0]; // original width
$origh = $arr[1]; // original height
if ($mime == 'image/jpeg') {$newimg = imagecreatefromjpeg($tempname);}
elseif ($mime == 'image/png') {$newimg = imagecreatefrompng($tempname);}
elseif ($mime == 'image/gif') {$newimg = imagecreatefromgif($tempname);}
if($origw > 960) {
$newimg = imagescale($newimg, 960);
}
现在我需要新图像的尺寸:
$arr = getimagesize($newimg);
$endw = $arr[0];
$endh = $arr[1];
警告:
getimagesize() expects parameter 1 to be string, resource given
有帮助吗?
答案 0 :(得分:0)
要获取图像的宽度和高度资源(在您的情况下,$newimg
具有资源类型),可以使用imagesx
/ { {3}}分别起作用:
$endw = imagesx($newimg);
$endh = imagesy($newimg);