现在的位置: 首页 > 综合 > 正文

php获得图像的属性函数

2013年04月19日 ⁄ 综合 ⁄ 共 514字 ⁄ 字号 评论关闭
<?php
/**
 * 取得图像信息
 * 
 * 用法:
 * --------------------------------------
 * $info = getImageInfo('test.jpg');
 * --------------------------------------
 * 
 * @param string $image 图像文件名
 * 
 * @return mixed
 */
function getImageInfo($image) {
    $imageInfo = getimagesize($image);
    if ($imageInfo !== FALSE) {
        $imageType = strtolower(substr(image_type_to_extension($imageInfo[2]), 1));
        $imageSize = filesize($image);
        $info = array(
            "width" => $imageInfo[0],
            "height" => $imageInfo[1],
            "type" => $imageType,
            "size" => $imageSize,
            "mime" => $imageInfo['mime']
        );
        return $info;
    } else {
        return FALSE;
    }
}
?>

抱歉!评论已关闭.