png transparency with PIL

Discussion in 'Python' started by Robin Becker, Nov 23, 2007.

  1. Robin Becker

    Robin Becker Guest

    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?
    --
    Robin Becker
     
    Robin Becker, Nov 23, 2007
    #1
    1. Advertising

  2. Robin Becker wrote:

    > 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

    --
    BOFH excuse #58:

    high pressure system failure
     
    Bjoern Schliessmann, Nov 23, 2007
    #2
    1. Advertising

  3. Robin Becker

    Robin Becker Guest

    Bjoern Schliessmann wrote:
    > Robin Becker wrote:
    >
    >> I'm trying to determine the transparency information for a png

    ..........
    >> 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
    >

    ........

    that sounds like what I need.
    --
    Robin Becker
     
    Robin Becker, Nov 23, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    2,616
  2. Jens Lenge

    PNG graphics transparency

    Jens Lenge, Oct 12, 2004, in forum: HTML
    Replies:
    9
    Views:
    432
    Jeffrey Silverman
    Oct 15, 2004
  3. Leif K-Brooks
    Replies:
    7
    Views:
    12,688
    Froggy
    Jul 20, 2009
  4. Caleb Hattingh
    Replies:
    2
    Views:
    2,082
    Caleb Hattingh
    Dec 1, 2004
  5. Jeff

    PNG transparency support

    Jeff, Feb 16, 2008, in forum: HTML
    Replies:
    12
    Views:
    616
    Raymond SCHMIT
    Mar 6, 2008
Loading...

Share This Page