标签:
/**
* 图像处理-获取图像信息
* @param string $source 源文件图片
* @return array(图片的宽、高、类型)
*/
function get_img_info($source) {
$imginfo = array();
$ext = strtolower(substr(strrchr($source, ‘.‘), 1)); //获取图片类型
$image_type = array(1 => ‘gif‘, 2 => ‘jpeg‘, 3 => ‘png‘, 6 => ‘bmp‘);
if (function_exists(‘read_exif_data‘) && in_array($ext, array(‘jpg‘, ‘jpeg‘, ‘jpe‘, ‘jfif‘))) { //jpeg情况
$temp = @read_exif_data($source);
$imginfo[‘width‘] = $temp[‘COMPUTED‘][‘Width‘];
$imginfo[‘height‘] = $temp[‘COMPUTED‘][‘Height‘];
$imginfo[‘type‘] = 2;
unset($temp);
}
if (empty($imginfo)) { //png,gif,bmp
list($imginfo[‘width‘], $imginfo[‘height‘], $imginfo[‘type‘]) = @getimagesize($source);
}
//$imginfo[‘type‘] = $image_type[$imginfo[‘type‘]];
$size = $imginfo[‘width‘] / $imginfo[‘height‘];
return round($size, 2); //取两位
}
标签:
原文地址:http://www.cnblogs.com/rickons/p/5461497.html