php获取图片宽高等属性

<?php
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;
    }
}
$info = getImageInfo('test.jpg');
var_dump($info);
?>
posted @ 2013-12-03 10:13  kwishly  阅读(550)  评论(0编辑  收藏  举报