php - 有没有一种简单的方法可以在没有 javascript 的情况下在 PHP 中将图像大小设为 "get"?

标签 php image

假设我有一张图片的 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");

还有imagesximagesy函数分别获取图像的宽度和高度。

关于php - 有没有一种简单的方法可以在没有 javascript 的情况下在 PHP 中将图像大小设为 "get"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2137217/

相关文章:

php - 如何创建新闻源(AJAX 新闻源)

php - 读取文件行和查询结果的编程函数

php - 在 Yii2 中一次保存多个模型

php - 如何在下拉列表值中添加逗号?

css - 让图像与 div 重叠并位于文本后面

android - 如何在文本中设置背景图像

python - 使用形态运算对圆进行计数

image - MATLAB - 如何从 .fig 文件中裁剪图像的某些部分并将其另存为 .mat?

javascript - 使用 jQuery 迭代特定的 CSS-id

swift - cell.imageView!.frame 尺寸变化。 swift