I landed here today to find a way to tell (via php) if the particular .png image is alpha png one -
David Jones answer points in the right direction, very easy to implement in php:
file_get_contents to download only this 25-byte (here it is, really!) and
ord () to get its ASCII value to check it (against "6" in my case)
if(ord(file_get_contents($alpha_png_candidate, NULL, NULL, 25, 1)) == 6) { is_alpha_png_so_do_something(); }
In fact, I need this to ensure backward compatibility with ie6 in cms-user-generated-pages, to replace all alpha-png <img> with the built-in <spans> block - then the alpha-png file will be used as a variable for ms-patented CSS Property Filter
.alpha_png_span{ filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( src='$alpha_png_candidate', sizingMethod='crop') }
... and everything works, so thanks!
paolo
pikappa73
source share