php获取图片尺寸(宽度,高度)

语法:array getimagesize( string filename [, array &imageinfo] )php

功能:getimagesize()函数将测定任何GIF,JPG,PNG,SWF,SWC,PSD,TIFF,BMP,IFF,JP2,JPX,JB2,JPC,XBM或WBMP图像文件并返回文件的大小,尺寸,文件类型以及一个能够用于普通HTML文件中<IMG>标记中的 height/width 文本字符串。若是不能访问指定的图像或者其不是有效的图像,getimagesize()将返回FALSE并产生一条E_WARNING级的错误。函数

 

注:code

(1)本函数不须要 GD 图像库支持。图片

(2)该函数除了能够获取本地图片或者Flash的相关信息外还能够直接用来获取远程的。字符串

示例:get

1 <?php
2 list($width,$height,$type,$attr)=getimagesize("http://www.phpernote.com/images/logo.gif");
3 echo "Image width ".$width;
4 echo "<br/>";
5 echo "Image height ".$height;
6 echo "<br/>";
7 echo "Image type ".$type;
8 echo "<br/>";
9 echo "Attribute ".$attr;

输出信息以下:string

Image width 200
Image height 55
Image type 1
Image attribute width="200" height="55"table

其中图片类型的参数参考以下:
1 = GIF  5 = PSD  9 = JPC  13 = SWC
2 = JPG  6 = BMP  10 = JP2  14 = IFF
3 = PNG  7 = TIFF(intel byte order)  11 = JPX  15 = WBMP
4 = SWF  8 = TIFF(motorola byte order)  12 = JB2  16 = XBMfile

相关文章
相关标签/搜索