note 105033 modified in function.getimagesize by danbrown
| From: | danbrown@php.net | Date: | Mon, 25 Jul 2011 12:27:41 +0000 |
| Subject: | note 105033 modified in function.getimagesize by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181831@lists.php.net to get a copy of this message | ||
Here is the function which determines whether the PNG image contains alpha or not:
<?php
function is_alpha_png($fn){
return (ord(@file_get_contents($fn, NULL, NULL, 25, 1)) == 6);
}
?>
The color type of PNG image is stored at byte offset 25. Possible values of that 25'th byte is:
* 0 - greyscale
* 2 - RGB
* 3 - RGB with palette
* 4 - greyscale + alpha
* 6 - RGB + alpha
--was--
Here is the function which determines whether the PNG image contains alpha or not:
function is_alpha_png($fn){
return (ord(@file_get_contents($fn, NULL, NULL, 25, 1)) == 6);
}
The color type of PNG image is stored at byte offset 25. Possible values of that 25'th byte is:
* 0 - greyscale
* 2 - RGB
* 3 - RGB with palette
* 4 - greyscale + alpha
* 6 - RGB + alpha
http://php.net/manual/en/function.getimagesize.php