PIL 1.1.4 paste PNG's with transparency problem

Caleb Hattingh caleb1 at telkomsa.net
Mon Nov 29 23:12:43 EST 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



More information about the Python-list mailing list