<?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中获取位深度