Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PIL 1.1.4 paste PNG's with transparency problem

Reply
Thread Tools

PIL 1.1.4 paste PNG's with transparency problem

 
 
Caleb Hattingh
Guest
Posts: n/a
 
      11-30-2004
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
 
Reply With Quote
 
 
 
 
Tom Hanks
Guest
Posts: n/a
 
      11-30-2004
"Caleb Hattingh" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> >>> iconBallImage.paste(iconShieldImage, (10,10))


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

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

TTFN
Tom.
 
Reply With Quote
 
 
 
 
Caleb Hattingh
Guest
Posts: n/a
 
      12-01-2004
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 <(E-Mail Removed)>
wrote:

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

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

> ^^^^^^^^^^^^^^^
> transparency as 3rd
> parameter
>
> TTFN
> Tom.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PIL: Transparent PNGs and im.paste: ValueError: bad transparency mask Durand Python 0 07-10-2008 08:31 PM
Newbie : Gif transparency with Pil problem. Gustavo Campanelli Python 2 12-16-2003 02:42 PM
PIL & TIFF transparency? Robin Becker Python 2 07-31-2003 08:01 AM
Transparency with PIL and paste ? jean-Baptiste Cazier Python 0 07-23-2003 11:33 AM
PIL and transparency in IE Marek Python 0 06-26-2003 07:08 AM



Advertisments