png transparency with PIL

R

Robin Becker

I'm trying to determine the transparency information for a png image. With gif
images I can determine the colour that is used for transparent areas using
im.info['transparency']. For the png images of interest there is no such entry
in the info dict. I assume that's because of the way png does transparency. I'm
guessing I need the alpha channel, but is there a way to get hold of it?
 
B

Bjoern Schliessmann

Robin said:
I'm trying to determine the transparency information for a png
image. With gif images I can determine the colour that is used for
transparent areas using im.info['transparency']. For the png
images of interest there is no such entry in the info dict. I
assume that's because of the way png does transparency. I'm
guessing I need the alpha channel, but is there a way to get hold
of it?

For accessing the alpha channel, there is an RGBA mode for PNG
files:

http://www.pythonware.com/library/pil/handbook/format-png.htm

Regards,


Björn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top