List Info

Thread: Paste RGBA to RGBA bug




Paste RGBA to RGBA bug
user name
2006-05-19 00:05:50
Hi,

I'm trying to paste an RGBA image onto another RGBA image
but the 
blending is not working as I would expect it to.

The code is something like this, where src and dst are both
RGBA:

src = Image.open( 'img.png' )
dst = Image.open( 'img2.png' )
dst.paste( src, None, src )

What I expect to happen is that the alpha value of 'dst'
stays the same. 
However, what actually happens is that the new alpha value
is being 
computed by blending 'src' alpha and 'dst' alpha
together.

It could be argued that this is the desired behaviour, but I
don't think 
that it isn't consistent with other cases of using paste.
In fact I 
found a workaround that behaves how I would expect it to.
The trick is 
to convert src to a RGB image first, then just use the
original src as 
the mask.

src = Image.open( 'img.png' )
dst = Image.open( 'img2.png' )
srcRGB = src.convert( 'RGB' )
dst.paste( srcRGB, None, src )

Actually I did a search and found that this same problem has
come up 
before in this thread:
http://www.mail
-archive.com/image-sigpython.org/msg00773.html

Cheers,

James Sayer
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )