PIL 1.1.4 paste PNG's with transparency problem

Discussion in 'Python' started by Caleb Hattingh, Nov 30, 2004.

  1. Here's hoping effbot is around :)

    I have a really simple situation where I have 2 png images, and open them
    so:

    '>>> iconBallImage =
    Image.open('sampleTextures/iconBall.png').resize(DimensionSize)
    '>>> iconShieldImage =
    Image.open('sampleTextures/iconShield.png').resize(DimensionSize)

    The 2nd image has an alpha channel with transparency. The first one also
    has an alpha channel, but is fully opaque. Then I paste the second image
    into the first image:

    '>>> iconBallImage.paste(iconShieldImage, (10,10))

    Then I save:

    '>>> iconBallImage.save('sampleTextures/output.png')

    When I view "output.png" in the Gimp, I see that the transparent bits in
    the second image appear as a grey-crosshatching pattern. There is an
    alpha channel in the new image, but I expected to see that bits of the
    original first image would peer through the transparent bits of the
    original second image.

    I fully expect I am doing something wrong here, I just don't know what.

    Thanks
    Caleb
     
    Caleb Hattingh, Nov 30, 2004
    #1
    1. Advertising

  2. Caleb Hattingh

    Tom Hanks Guest

    "Caleb Hattingh" <> wrote in message news:<>...
    > >>> iconBallImage.paste(iconShieldImage, (10,10))


    >>> iconBallImage.paste(iconShieldImage, (10,10), iconShieldImage)

    ^^^^^^^^^^^^^^^
    transparency as 3rd parameter

    TTFN
    Tom.
     
    Tom Hanks, Nov 30, 2004
    #2
    1. Advertising

  3. Wow, that was pretty clueless of me...right there on the *next* page of
    the manual (I thought "im.paste(image, box)" and "im.paste(image, color)"
    were the general forms for "paste", apparently didn't look further)

    thx
    Caleb

    On 29 Nov 2004 22:17:36 -0800, Tom Hanks <>
    wrote:

    > "Caleb Hattingh" <> wrote in message
    > news:<>...
    >> >>> iconBallImage.paste(iconShieldImage, (10,10))

    >
    >>>> iconBallImage.paste(iconShieldImage, (10,10), iconShieldImage)

    > ^^^^^^^^^^^^^^^
    > transparency as 3rd
    > parameter
    >
    > TTFN
    > Tom.
     
    Caleb Hattingh, Dec 1, 2004
    #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,624
  2. jean-Baptiste Cazier

    Transparency with PIL and paste ?

    jean-Baptiste Cazier, Jul 23, 2003, in forum: Python
    Replies:
    0
    Views:
    643
    jean-Baptiste Cazier
    Jul 23, 2003
  3. Robin Becker

    png transparency with PIL

    Robin Becker, Nov 23, 2007, in forum: Python
    Replies:
    2
    Views:
    423
    Robin Becker
    Nov 23, 2007
  4. Durand
    Replies:
    0
    Views:
    1,028
    Durand
    Jul 10, 2008
  5. zik

    png transparency and IE problem

    zik, Apr 9, 2008, in forum: Javascript
    Replies:
    4
    Views:
    138
    Doug Gunnoe
    Apr 10, 2008
Loading...

Share This Page