ConFoo Montreal 2026: Call for Papers

Voting

: max(eight, four)?
(Example: nine)

The Note You're Voting On

kroccamen, gmail
17 years ago
Sorry, below should be:

<?php
$is_alpha
= ord (file_get_contents ($file_path, false, null, 25, 1)) & 4;
?>

much better :)
Both types 4 (greyscale transparent png), and 6 (colour transparent png) have bit 4 set, so there's no need to bitwise twice and there's no need for == as the return value will be 4 or 0, which is easily interpreted as true or false elsewhere in your code.

note: file_get_contents isn't reading the whole file in this instance, just 1 byte on its own and that's it, so you can be assured this is fast and safe.

<< Back to user notes page

To Top