PHP image dimension

我只是一个虾纸丫 提交于 2020-01-06 14:27:24

问题


How to get width and height of an image?

I have $variable = 'http://site.com/image.png"

Want to get width of this image to $width and height to $height.

Like: $variable = 'http://site.com/image.png"

$width = '300'; // image width is 300px
$height = '500'; // height is 500px

Thanks.


回答1:


$variable = 'http://site.com/image.png';
$image    = getimagesize($variable);
$width    = $image[0];
$height   = $image[1];
$type     = $image[2];



回答2:


getimagesize function. Maybe it will help you.



来源:https://stackoverflow.com/questions/3510329/php-image-dimension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!