I a bit tardy as explained by my Spam msg just posted. This is a very
difficult list to post to for several reasons just mentioned in a msg I
posted a few minutes ago.
Interesting. Thanks. I did get what I was looking for (just posted a few
mins ago), but this has some good twists.
Denilson Figueiredo de Sá wrote:
Hello, I think I found a bug/limitation in PIL.
If I have a PNG with palette, and with semi-transparent colors at that
palette, then PIL will ignore the semi-transparent information. In
other words, it will always load the palette as RGB, instead of RGBA.
Let's reproduce the bug, step-by-step:
1. Create an RGBA image using Gimp. Or, even easier, download this one
I created:
http://denilsonsa.selfip.org/~denilson/pil/rgba.png
2. Convert that image to RGBA palette. What I've done was:
cp pil_rgba.png pil_palette.png
optipng -o7 pil_palette.png
You can download optipng at http://optipng.sourceforge.net/
Or you can download the converted image here:
http://denilsonsa.selfip.org/~denilson/pil/palette.png
3. Try opening it using PIL, convert back to RGBA, and save as PNG:
from PIL import Image
f = Image.open("pil_palette.png")
print f.palette.mode # This will print RGB, but should be RGBA
f = f.convert("RGBA")
f.save("pil_saved.png")
Or you can download it from here:
http://denilsonsa.selfip.org/~denilson/pil/saved.png
== What did I expect? ==
I expected that PIL would correctly load RGBA palette, and thus
correctly preserve the semi-transparent information. I expected that
the pil_saved.png file still looked the same as pil_rgba.png.
== What actually happens? ==
PIL throws away the Alpha channel, and the final pil_rgba.png image
has all semi-transparent pixels converted to opaque.
== Extra information ==
The "feh" image viewer correctly supports RGBA palettes. Also, I think
it is a better replacement for xv, for use in image.show()
http://www.linuxbrit.co.uk/feh
Both Firefox and Opera browsers correctly support RGBA palettes.
Surprisingly, Gimp does not support RGBA palettes, and will convert
semi-transparent colors to full transparency.
== Similar messages ==
While searching, I found these messages about the same subject:
25 Jan 2009 -
http://www.mail-archive.com/image-sig@python.org/msg02275.html
15 Nov 2008 -
http://www.mail-archive.com/image-sig@python.org/msg02182.html
27 Aug 2008 -
http://www.mail-archive.com/image-sig@python.org/msg02065.html
26 Jan 2005 -
http://www.mail-archive.com/image-sig@python.org/msg00069.html
I'm not subscribed to this mail list, so please add me to CC when
replying to this message.
Thanks.
--
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****
"In arithemtic as in politics, the importance of one is
determined by the number of zeros behind it." -- Anon
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig