PHP获取图片大小函数。 getimagesize() 能够得到图片及flash(swf)的大小。
语法
1
|
list( $width , $height , $type , $attr ) = getimagesize ( "image_name.jpg" ); |
下面是一个实例程序,将image_name.jpg改为您的图片地址
01
02
03
04
05
06
07
08
09
10
11
12
13
|
<?php list( $width , $height , $type , $attr ) = getimagesize ( "image_name.jpg" ); echo "Image width " . $width ; echo "<BR>" ; echo "Image height " . $height ; echo "<BR>" ; echo "Image type " . $type ; echo "<BR>" ; echo "Attribute " . $attr ; ?> |
运行这个脚本,你会看到如下结果:
Image width 379
Image height 344
Image type 2
Image attribute width="379" height="344"
你能够轻易的得到图片的宽度,高度及类型。
图片的类型:
1 = GIF5 = PSD9 = JPC13 = SWC
2 = JPG6 = BMP10 = JP214 = IFF
3 = PNG7 = TIFF(intel byte order)11 = JPX15 = WBMP
4 = SWF8 = TIFF(motorola byte order)12 = JB216 = XBM