假设我有一张图片的 URL,有没有一种简单的方法可以使用 PHP 获取它的高度/宽度? 如果可能,我不想使用 javascript。
最佳答案
你可以使用 getimagesize
The getimagesize() function will determine the size of any given image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML tag and the correspondant HTTP content type.
Returns an array with 7 elements.
Index 0 and 1 contains respectively the width and the height of the image.
list($width, $height, $type, $attr) = getimagesize("yourimage.jpg");
关于php - 有没有一种简单的方法可以在没有 javascript 的情况下在 PHP 中将图像大小设为 "get"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2137217/