[Image-SIG] PIL: Unexpected results with Image.paste on RGBA images with transparency.
Alex Clark
aclark at aclark.net
Tue Oct 30 00:24:45 CET 2012
Hi Lars,
On Mon, Oct 29, 2012 at 4:05 PM, Lars Ruoff <lars.ruoff at gmail.com> wrote:
> Any other comments?
>
> Alex,
>
> Pillow says:
> Please report any non-packaging related issues here first:
>
> - https://bitbucket.org/effbot/pil-2009-raclette/issues
>
>
> Should i report the issue there?
>
Yes please.
>
> Lars
>
>
>
> On Mon, Oct 29, 2012 at 4:33 PM, Alex Clark <aclark at aclark.net> wrote:
>
>> On 2012-10-29 15:05:28 +0000, Lars Ruoff said:
>>
>> Hi,
>>>
>>> I'm new to this list, so excuse me if this is a known issue.
>>> I didn't find anything on it on the net so far but didn't have time to
>>> search much.
>>>
>>> I have observed what i consider a flaw in the Image.paste algorithm when
>>> used with transparent images.
>>>
>>> transparent-columns.png is an image with 3 vertical black columns with
>>> alpha=0.5, 0.2 and transparent respectively.
>>> transparent-bars.png is an image with 2 horizontal black bars with
>>> transparent and alpha=0.5 respectively.
>>> (images attached)
>>>
>>> When these two images are transparently pasted one over the other, using
>>> the following code:
>>>
>>> from PIL import Image
>>> source = Image.open('transparent-**columns.png')
>>> result = Image.open('transparent-bars.**png')
>>> result.paste(source, (0, 0), source)
>>> result.save('transparent-**columns-on-bars-pil.png')
>>>
>>> The result is unexpectet to say the least.
>>> PIL seems to modify the transparency even in regions where only one of
>>> the images has non-transparent values.
>>> Very wrong in my opinion.
>>>
>>> Doing the same manipulation in GIMP 2.6 gives what i consider the
>>> expected result.
>>> (attached for reference)
>>>
>>> I guess the per-pixel transparency of the result should be result_alpha
>>> = 1 - (1-alpha1)*(1-alpha2),
>>> where alpha1,alpha2 are the alpha channel values from the original
>>> images.
>>>
>>
>>
>> You are welcome to submit a patch to Pillow (the "friendly" PIL fork)
>> here:
>>
>> - https://github.com/python-**imaging/Pillow<https://github.com/python-imaging/Pillow>
>>
>>
>> Speaking of that, can anyone review:
>>
>> - https://github.com/python-**imaging/Pillow<https://github.com/python-imaging/Pillow>
>>
>>
>> Also, I'm looking for a few folks willing to "stand up" and regularly
>> review image code fixes. I know nothing about that code, and plan to stick
>> with being the release manager only. I'll be doing a 1.7.8 release soon (by
>> the end of this month) then maybe Pillow 1.8 will contain support for
>> Python 3.3 (and cut everything before 2.7).
>>
>>
>>
>>> Regards,
>>> Lars Ruoff
>>>
>>> <image>
>>> <image>
>>> <image>
>>> <image>
>>> <image>
>>> <image>
>>> ______________________________**_________________
>>> Image-SIG maillist - Image-SIG at python.org
>>> http://mail.python.org/**mailman/listinfo/image-sig<http://mail.python.org/mailman/listinfo/image-sig>
>>>
>>
>>
>> --
>> Alex Clark · https://www.gittip.com/**aclark4life/<https://www.gittip.com/aclark4life/>
>>
>>
>> ______________________________**_________________
>> Image-SIG maillist - Image-SIG at python.org
>> http://mail.python.org/**mailman/listinfo/image-sig<http://mail.python.org/mailman/listinfo/image-sig>
>>
>
>
--
Alex Clark · http://aclark.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20121029/353bafc2/attachment-0001.html>
More information about the Image-SIG
mailing list