<div>Hi,</div><div><br></div><div>I'm new to this list, so excuse me if this is a known issue.</div><div>I didn't find anything on it on the net so far but didn't have time to search much.</div><div><br></div><div>
I have observed what i consider a flaw in the Image.paste algorithm when used with transparent images.</div><div><br></div><div>transparent-columns.png is an image with 3 vertical black columns with alpha=0.5, 0.2 and transparent respectively.</div>
<div>transparent-bars.png is an image with 2 horizontal black bars with transparent and alpha=0.5 respectively.</div><div>(images attached)</div><div><br></div><div>When these two images are transparently pasted one over the other, using the following code:</div>
<div><br></div><div>from PIL import Image</div><div>source = Image.open('transparent-columns.png')</div><div>result = Image.open('transparent-bars.png')</div><div>result.paste(source, (0, 0), source)</div>
<div>result.save('transparent-columns-on-bars-pil.png')</div><div><br></div><div>The result is unexpectet to say the least.</div><div>PIL seems to modify the transparency even in regions where only one of the images has non-transparent values.</div>
<div>Very wrong in my opinion.</div><div><br></div><div>Doing the same manipulation in GIMP 2.6 gives what i consider the expected result.</div><div>(attached for reference)</div><div><br></div><div>I guess the per-pixel transparency of the result should be result_alpha = 1 - (1-alpha1)*(1-alpha2),</div>
<div>where alpha1,alpha2 are the alpha channel values from the original images.</div><div><br></div><div>Regards,</div><div>Lars Ruoff</div><div><br></div>