PHP的函数获取图片的宽高等信息

PHP的函数getimagesize可以得到图片的宽高等信息

array getimagesize ( string $filename [, array &$imageinfo ] )
 

返回一个具有四个单元的数组。索引 0 包含图像宽度的像素值,索引 1 包含图像高度的像素值。索引 2 是图像类型的标记:1 = GIF,2 = JPG,3 = PNG,4 = SWF,5 = PSD,6 = BMP,7 = TIFF(intel byte order),8 = TIFF(motorola byte order),9 = JPC,10 = JP2,11 = JPX,12 = JB2,13 = SWC,14 = IFF,15 = WBMP,16 = XBM。这些标记与 PHP 4.3.0 新加的 IMAGETYPE 常量对应。索引 3 是文本字符串,内容为“height="yyy" width="xxx"”,可直接用于 IMG 标记。
这是PHP官网的手册:http://php.net/manual/en/function.get...
补充一个demo:

$images_array = array("http://static.zend.com/img/logo.gif");
foreach($images_array as $image)
{
        list($width, $height, $type, $attr) = getimagesize($image);
        $new_height = (int)(192 / $width * $height);
        echo '<li><img src="'.$image.'" width="192px" height="'.$new_height.'" />';
}

 

转载于:https://www.cnblogs.com/bluealine/p/11040752.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值