Thread

Posted on Tue Feb 22 19:09:35 2005 by meista
How to create IE compatible transparent PNG's ?
Hello, im trying to create a image with a transparent background.
But i want it without Alpha Channel because IE does not like this..
If i disable the alpha channel i get a picture with a black background.
What i am doing wrong?

Mike
#----- Some Code ------
my $image = Image::Imlib2->load("$libdir/icons/transparent.png"); $image=$image->create_scaled_image($w,$h); $image->add_font_path("$libdir/fonts"); # ... #draw some text # ... $image->has_alpha(0); #save out $image->image_set_format("png"); $image->set_quality(75); $image->save("/tmp/$$"."out.png");
Direct Responses: 143 | Write a response
Posted on Tue Feb 22 21:01:48 2005 by geoffalot in response to 141
Re: How to create IE compatible transparent PNG's?
You can handle pngs for IE on the client side, and not worry about the server side. Note - this doesn't work for background images. You need to put the filter code into the css for that to work (http://www.daltonlp.com/daltonlp.cgi?item_type=1&item_id=217). As well, as an fyi, background png images don't work on IE for the Mac, and Netscape 6 all. (if you care about those) Place this code in a global css file. (or at the file level, if you prefer. Code is PHP with ASP tags, customize to perl as you see fit)
<style type="text/css"> <% if (IE){ %> img { visibility:hidden; behavior: url(css/png.htc); } <% } %> </style>
Then save this code as "png.htc". The spacerImage (a transparent gif image) variable needs to be correct for this to work.
<PUBLIC:COMPONENT lightWeight="true"> <PUBLIC:ATTACH EVENT="oncontentready" ONEVENT="filterImage()" /> <SCRIPT LANGUAGE="JScript"> var orignalImage = element.src; var spacerImage = "images/spacer.gif"; var htcCapable = /MSIE ((5\.5)|[6])/.test(navigator.userAgent) && navigator.platform == "Win32"; function filterImage() { if(/\.png$/.test(orignalImage)) { if(htcCapable) { element.src = spacerImage; element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + orig +nalImage + ",sizingMethod='scale')"; } } element.style.visibility = 'visible'; } </SCRIPT> </PUBLIC:COMPONENT>
geoff geoffrey@geoffreymoller.com
Direct Responses: 144 | Write a response
Posted on Tue Feb 22 21:56:01 2005 by meista in response to 143
Re: How to create IE compatible transparent PNG's?
Hi,
thanks for that trick.
Im sure this works, but what it want are not semi-transparent images.
i just need a image with some fully transparent areas.
Image
IE can handle them for sure if the image uses RGB instead of RGBA.
I want Users to include this into their signature and everything more than 3 Lines is too complicated ;)
Write a response