473,528 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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('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
Jul 18 '05 #1
2 6219
"Caleb Hattingh" <ca****@telkomsa.net> wrote in message news:<op**************@news.telkomsa.net>...
iconBallImage.paste(iconShieldImage, (10,10)) iconBallImage.paste(iconShieldImage, (10,10), iconShieldImage)

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

TTFN
Tom.
Jul 18 '05 #2
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 <ga****************@hotmail.com>
wrote:
"Caleb Hattingh" <ca****@telkomsa.net> wrote in message
news:<op**************@news.telkomsa.net>...
>>> iconBallImage.paste(iconShieldImage, (10,10)) iconBallImage.paste(iconShieldImage, (10,10), iconShieldImage)

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

TTFN
Tom.


Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5651
by: Cecile Muller | last post by:
I've been trying to just open a png and display it, that way: <? header ("Content-type: image/png"); $im = imagecreatefrompng('empty.png'); imagepng($im); ?> But the transparency is not kept. I did try in netscape too, but it's visible even in explorer, when comparing how the
57
3905
by: Piotr Wolski | last post by:
how to make my page that it was correct with every browser standard? for example when i change HTML's table size it has no effect when i see it under mozilla and has effect under Internet explorer-does anyone know how to solve that problem??
14
1840
by: eastcoastguyz | last post by:
As I am learning PHP and seeing examples of handling graphics using the imagecreate functions. The few examples I have run across use PNG as the graphic file format of choice. Is there a reason for that? I have used JPG and GIF files, and I have to admit until recently I've not heard of (didn't have a reason to pay attention to) PNG files...
4
11633
by: R.Marquez | last post by:
I am trying to create a simple script that Opens an existing PNG and resaves it with a transparent color. With the command line version of ImageMagic this is an easy endevor (and my current solution). I can simply do something like: convert -transparent black image.png image-transparent.png (That makes anything black transparent in the...
1
2697
by: dragze | last post by:
Hi, On one of the pages of my site i use two javascripts, one makes transparency of png's work in IE, and the other embeds a flash player. Now use one of the scripts it works fine, use both and the transparency script stops working. So for example, use just the png transparency script and it displays the png's correctly in IE, as soon as i add...
3
4206
by: Martijn Mulder | last post by:
When I populate a ToolStrip with ToolStripButtons with a .png-image on it, will Windows understand the transparency of the .png file?
2
1797
by: Robin Becker | last post by:
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. 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...
2
4798
XedinUnknown
by: XedinUnknown | last post by:
Hi! I am new to this forum, but not new to web design and programming. Nevertheless, I have never tried to use PNG so extensively in my pages. here's the problem. First, I have found that the PNG backgrounds and images had no transparency and grey around them when viewed in IE6, but I solved this bug using this hack. It works great, but then...
0
4160
by: Durand | last post by:
Hi! I'm trying to paste a png with a transparent layer into an image using "image.paste(tesla,(20,10), tesla)" but I'm getting this error: ValueError: bad transparency mask I have used im.paste(image,box,image) sucessfully before to paste an image with transparency, however, it doesn't seem to work for this particular image. How would I...
0
7332
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7255
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7657
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7242
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3319
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3322
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
894
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.