如何从图像PNG获取位深度?

时间:2011-06-21 10:57:52

标签: php image png bit-depth

  

可能重复:
  How to PHP get bit depth of a given PNG image file?

<?php

class ImageType {
    //type of image
    const JPG = 'image/jpeg';
    const BMP = 'image/x-ms-bmp';
    const GIF = 'image/gif';
    const PNG = 'image/png';
}

$imagePath = 'ga32bit.png';

$info = getImageSize($imagePath);

$imageType = $info['mime'];

if ($imageType == ImageType::BMP || $imageType == ImageType::GIF)
    echo $imagePath . ':' . $info['bits'];
else if ($imageType == ImageType::JPG)
    echo $imagePath . ':' . $info['bits'] * $info['channels'];
else if ($imageType == ImageType::PNG) {

    $imgPNG = imagecreatefrompng($imagePath);

    $trueColor = imageistruecolor($imgPNG);

    if ($trueColor == 0)
        echo $imagePath . ':' . $info['bits'];
    else {//????????
        echo $info['bits']; //--> 8 --> not correct
        //????
    }
}
?>

如何从图像PNG中获取位深度

0 个答案:

没有答案