PIL 1.1.4 paste PNG's with transparency problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Caleb Hattingh

    PIL 1.1.4 paste PNG's with transparency problem

    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('sam pleTextures/iconBall.png'). resize(Dimensio nSize)
    '>>> iconShieldImage =
    Image.open('sam pleTextures/iconShield.png' ).resize(Dimens ionSize)

    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.p aste(iconShield Image, (10,10))

    Then I save:

    '>>> iconBallImage.s ave('sampleText ures/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
  • Tom Hanks

    #2
    Re: PIL 1.1.4 paste PNG's with transparency problem

    "Caleb Hattingh" <caleb1@telkoms a.net> wrote in message news:<opsh9fbhw c1js0xs@news.te lkomsa.net>...[color=blue][color=green][color=darkred]
    > >>> iconBallImage.p aste(iconShield Image, (10,10))[/color][/color][/color]
    [color=blue][color=green][color=darkred]
    >>> iconBallImage.p aste(iconShield Image, (10,10), iconShieldImage )[/color][/color][/color]
    ^^^^^^^^^^^^^^^
    transparency as 3rd parameter

    TTFN
    Tom.

    Comment

    • Caleb Hattingh

      #3
      Re: PIL 1.1.4 paste PNG's with transparency problem

      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 <garbagecollect or86@hotmail.co m>
      wrote:
      [color=blue]
      > "Caleb Hattingh" <caleb1@telkoms a.net> wrote in message
      > news:<opsh9fbhw c1js0xs@news.te lkomsa.net>...[color=green][color=darkred]
      >> >>> iconBallImage.p aste(iconShield Image, (10,10))[/color][/color]
      >[color=green][color=darkred]
      >>>> iconBallImage.p aste(iconShield Image, (10,10), iconShieldImage )[/color][/color]
      > ^^^^^^^^^^^^^^^
      > transparency as 3rd
      > parameter
      >
      > TTFN
      > Tom.[/color]

      Comment

      Working...