From bb01e845ea4ccdd84acedaa82818d17034c212d0 Mon Sep 17 00:00:00 2001 From: Allen Li Date: Wed, 8 Apr 2015 15:57:17 -0400 Subject: [PATCH 1/4] Clarify docstring about mask values [ci skip] The behavior of paste() with regard to intermediate mask values was unclear, so this commit clarifies how it works. --- PIL/Image.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PIL/Image.py b/PIL/Image.py index 7cfa72e6f..e6f5327be 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1288,7 +1288,13 @@ class Image: images (in the latter case, the alpha band is used as mask). Where the mask is 255, the given image is copied as is. Where the mask is 0, the current value is preserved. Intermediate - values can be used for transparency effects. + values will mix the two images together. If this image has an + alpha channel, intermediate values will also set the alpha + channel to themselves. + + See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to + combine images with a partial mask without setting the alpha + channel. Note that if you paste an "RGBA" image, the alpha band is ignored. You can work around this by using the same image as From 7674694185c4899d679a1c16b5118d397e213204 Mon Sep 17 00:00:00 2001 From: Allen Li Date: Fri, 10 Apr 2015 23:23:26 -0400 Subject: [PATCH 2/4] Correct description of paste() behavior [ci skip] --- PIL/Image.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index e6f5327be..a2f9be15c 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1288,9 +1288,8 @@ class Image: images (in the latter case, the alpha band is used as mask). Where the mask is 255, the given image is copied as is. Where the mask is 0, the current value is preserved. Intermediate - values will mix the two images together. If this image has an - alpha channel, intermediate values will also set the alpha - channel to themselves. + values will mix the two images together, including their alpha + channels if they have them. See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to combine images with a partial mask without setting the alpha From c6d410ff3b13ecf25381178ca35c149b31d6c519 Mon Sep 17 00:00:00 2001 From: Allen Li Date: Fri, 10 Apr 2015 23:24:30 -0400 Subject: [PATCH 3/4] Correct description of alpha-composite [ci skip] --- PIL/Image.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index a2f9be15c..be27bd99b 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1292,8 +1292,7 @@ class Image: channels if they have them. See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to - combine images with a partial mask without setting the alpha - channel. + combine images with respect to their alpha channels. Note that if you paste an "RGBA" image, the alpha band is ignored. You can work around this by using the same image as From e8107e3bbbd48f5713f6c2de2539718e243fe7c2 Mon Sep 17 00:00:00 2001 From: Allen Li Date: Fri, 10 Apr 2015 23:25:15 -0400 Subject: [PATCH 4/4] Remove wrong docstring about RGBA paste [ci skip] Pasting RGBA images does preserve the alpha channel if the current image has an alpha channel. --- PIL/Image.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index be27bd99b..36ff2eebf 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1294,10 +1294,6 @@ class Image: See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to combine images with respect to their alpha channels. - Note that if you paste an "RGBA" image, the alpha band is - ignored. You can work around this by using the same image as - both source image and mask. - :param im: Source image or pixel value (integer or tuple). :param box: An optional 4-tuple giving the region to paste into. If a 2-tuple is used instead, it's treated as the upper left