开发者

Is there an easy way to "get" an image's size in PHP without javascript?

Say I have the URL of an image, 开发者_开发技巧is there an easy way to get it's height/width using PHP? I'd prefer not to use javascript if possible.


You could use 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");

Also there is imagesx and imagesy functions to get width and height of images individually.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜