I am trying to distinguish PNG-8 and PNG-24 images with getimagesize
or Imagick, but I don't quite know how to to it.
getimagesize
does not return channels for my PNGs and displays the mimetype instead. It works well for other images and shows the correct values, but for PNG it just shows nothing.
edit: Imagick is not installed in my environment but gdlib is...
Can anyone help me a bit?
Greetings,
Tomedit2: Is it possible to do it like开发者_开发知识库 this?
//create png for tests
$testPng = imagecreatefrompng( $file );
//test how many colors are used
$meta .= 'colors: ' . imagecolorstotal( $testPng );
$meta .= ' truecolor: ' . imageistruecolor( $testPng );
//destroy the test image
imagedestroy( $testPng );
And if truecolor is false or not set, it is a png24?
Take a look at How can I read PNG Metadata from PHP?
getimagesize()
seems to do the trick:
bits
is the number of bits for each color.
doesn't even need GD.
精彩评论