<?
$img="img/black.gif";
$imginfo=getimagesize($img);
$width=$imginfo[0];
$height=$imginfo[1];
echo $width." ".$height."<br>".$imginfo[3];
?>

解决方案 »

  1.   

    getimagesize()
    本函式可用来取得 GIF、JPEG 及 PNG 三种 WWW 上图片的高与宽,不需要安装 GD library 就可以使用本函式。传回的阵列有四个元素。传回阵列的第一个元素 (索引值 0) 是图片的高度,单位是像素 (pixel)。第二个元素 (索引值 1) 是图片的宽度。第三个元素 (索引值 2) 是图片的档案格式,其值 1 为 GIF 格式、 2 为 JPEG/JPG 格式、3 为 PNG 格式。第四个元素 (索引值 3) 为图片的高与宽字串,height=xxx width=yyy。
      

  2.   

    Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 a flag indicating the type of the image. 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP. Index 3 is a text string with the correct "height=xxx width=xxx" string that can be used directly in an IMG tag.