Transparent PNG and PIL

R.Marquez ny_r_marquez at yahoo.com
Wed May 26 11:24:20 EDT 2004


I am trying to create a simple script that Opens an existing PNG and
resaves it with a transparent color.  With the command line version of
ImageMagic this is an easy endevor (and my current solution).  I can
simply do something like:

convert -transparent black image.png image-transparent.png

(That makes anything black transparent in the saved image.)

It would seem that using PIL would make this simmilarly simple, but so
far I have not found a simple clear explanation of how to do this.  If
someone has figured this out could you post it for the benefit of
mankind. ;)

On a somewat off topic matter (as far as Python goes), I see that
transparent PNGs, as created by tools such as image magic, do not
display transparent on MS Internet Explorer.  I know that this is
probably because of MS's draggin their feet on supporting standards. 
But, I noticed that with tools such as PaintShop Pro I can add
transparency to a PNG, and have it show correctly in IE.  Does it do
this by in effect creating a proprietary PNG format?

When adding transparency to the PNG file, PaintShop says that the
image needs to be reduced to a single, paletted, background layer.  It
then decreases the color depth to 256 colors. And then allows one to
set a color as transparent.  When saving the image it warns that no
alpha channel will be saved.  Nevertheless, the transparency is saved
correctly and displays correctly on all the tools I've tried.  Can
someone shed a little light on what is going on here?



More information about the Python-list mailing list