Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何检查图像的宽度和高度?
$image_size = getimagesize($image_temp);
数组的第三个元素显示:
width="1679" height="939"
我想知道如何检查图像的宽度是否超过 1000,如果是,我可以将宽度更改为 1000px;
感谢:D
使用第 0 个元素检查条件并自己生成输出,例如:
$size = getimagesize($image_temp); $width_and_height = $size[0] > 1000 ? 'width="1000"' : $size[3];
或者,如果您想保持高度:
$width_and_height = $size[0] > 1000 ? 'width="1000" height="'.$size[1].'"' : $size[3];