Transparent PNG and PIL
Fredrik Lundh
fredrik at pythonware.com
Wed May 26 14:13:17 EDT 2004
R.Marquez wrote:
> 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. ;)
if you have an 8-bit palette image (mode "P"), you can specify the
transparency color (as a color index) when you save the image:
im.save(filename, transparency=0)
for RGB images, you can use the putalpha methods to add a transparency
layer to the image (turning into a mode "RGBA" image).
> Does it do this by in effect creating a proprietary PNG format?
iirc, IE supports transparency masks for 8-bit palette images (mode "P"),
but it does not support transparency with true color images ("RGBA").
unless you use IE-specific filters, that is:
http://webfx.eae.net/dhtml/pngbehavior/pngbehavior.html
</F>
More information about the Python-list
mailing list