note 82032 added to function.imagecolortransparent
| From: | kroccamen at osu1 dot php dot net | Date: | Tue, 25 Mar 2008 12:44:59 +0000 |
| Subject: | note 82032 added to function.imagecolortransparent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137558@lists.php.net to get a copy of this message | ||
@wesley gunn:
Thank you very, very much for the code to determine if a PNG is 24 or 32-bit :)
Here's an improved version in one line without using a file-handle
<?php
$is_alpha = ((ord (
file_get_contents ($filename, false, null, 25, 1)
) & 6) & 4) == 4;
?>
Gives true for a PNG with alpha, false otherwise.
This cannot detect 8-bit PNGs with transparency, but you could do that by searching the file
contents for the presence of "PLTE" *AND* "tRNS".
----
Server IP: 92.48.74.199
Probable Submitter: 82.44.33.144
----
Manual Page -- http://www.php.net/manual/en/function.imagecolortransparent.php
Edit -- https://master.php.net/note/edit/82032
Del: integrated -- https://master.php.net/note/delete/82032/integrated
Del: useless -- https://master.php.net/note/delete/82032/useless
Del: bad code -- https://master.php.net/note/delete/82032/bad+code
Del: spam -- https://master.php.net/note/delete/82032/spam
Del: non-english -- https://master.php.net/note/delete/82032/non-english
Del: in docs -- https://master.php.net/note/delete/82032/in+docs
Del: other reasons-- https://master.php.net/note/delete/82032
Reject -- https://master.php.net/note/reject/82032
Search -- https://master.php.net/manage/user-notes.php