From fc354cabaa0e51cf36ac6489cc4c3318fa59d1eb Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 1 Jan 2019 14:11:52 +1100 Subject: [PATCH 1/4] Added method --- docs/reference/ImageChops.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/ImageChops.rst b/docs/reference/ImageChops.rst index 2e4e21f19..6c8f11253 100644 --- a/docs/reference/ImageChops.rst +++ b/docs/reference/ImageChops.rst @@ -34,6 +34,7 @@ operations in this module). .. autofunction:: PIL.ImageChops.lighter .. autofunction:: PIL.ImageChops.logical_and .. autofunction:: PIL.ImageChops.logical_or +.. autofunction:: PIL.ImageChops.logical_xor .. autofunction:: PIL.ImageChops.multiply .. py:method:: PIL.ImageChops.offset(image, xoffset, yoffset=None) From aa8f30eae83e0a52f4d5e445d05f90b3ae72f752 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 1 Jan 2019 14:14:22 +1100 Subject: [PATCH 2/4] Several methods require at least one mode 1 image --- src/PIL/ImageChops.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/PIL/ImageChops.py b/src/PIL/ImageChops.py index 89016730e..422811351 100644 --- a/src/PIL/ImageChops.py +++ b/src/PIL/ImageChops.py @@ -54,7 +54,7 @@ def invert(image): def lighter(image1, image2): """ Compares the two images, pixel by pixel, and returns a new image containing - the lighter values. + the lighter values. Note that at least one of the images must have mode "1". .. code-block:: python @@ -70,8 +70,8 @@ def lighter(image1, image2): def darker(image1, image2): """ - Compares the two images, pixel by pixel, and returns a new image - containing the darker values. + Compares the two images, pixel by pixel, and returns a new image containing + the darker values. Note that at least one of the images must have mode "1". .. code-block:: python @@ -88,7 +88,7 @@ def darker(image1, image2): def difference(image1, image2): """ Returns the absolute value of the pixel-by-pixel difference between the two - images. + images. At least one of the images must be "1" mode. .. code-block:: python @@ -107,7 +107,8 @@ def multiply(image1, image2): Superimposes two images on top of each other. If you multiply an image with a solid black image, the result is black. If - you multiply with a solid white image, the image is unaffected. + you multiply with a solid white image, the image is unaffected. At least + one of the images must be "1" mode. .. code-block:: python @@ -123,7 +124,8 @@ def multiply(image1, image2): def screen(image1, image2): """ - Superimposes two inverted images on top of each other. + Superimposes two inverted images on top of each other. At least one of the + images must be "1" mode. .. code-block:: python @@ -141,6 +143,7 @@ def add(image1, image2, scale=1.0, offset=0): """ Adds two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. + At least one of the images must be "1" mode. .. code-block:: python @@ -156,8 +159,9 @@ def add(image1, image2, scale=1.0, offset=0): def subtract(image1, image2, scale=1.0, offset=0): """ - Subtracts two images, dividing the result by scale and adding the - offset. If omitted, scale defaults to 1.0, and offset to 0.0. + Subtracts two images, dividing the result by scale and adding the offset. + If omitted, scale defaults to 1.0, and offset to 0.0. At least one of the + images must be "1" mode. .. code-block:: python @@ -172,7 +176,8 @@ def subtract(image1, image2, scale=1.0, offset=0): def add_modulo(image1, image2): - """Add two images, without clipping the result. + """Add two images, without clipping the result. At least one of the images + must be "1" mode. .. code-block:: python @@ -187,7 +192,8 @@ def add_modulo(image1, image2): def subtract_modulo(image1, image2): - """Subtract two images, without clipping the result. + """Subtract two images, without clipping the result. At least one of the + images must be "1" mode. .. code-block:: python @@ -202,7 +208,8 @@ def subtract_modulo(image1, image2): def logical_and(image1, image2): - """Logical AND between two images. + """Logical AND between two images. At least one of the images must be "1" + mode. .. code-block:: python @@ -217,7 +224,8 @@ def logical_and(image1, image2): def logical_or(image1, image2): - """Logical OR between two images. + """Logical OR between two images. At least one of the images must be "1" + mode. .. code-block:: python @@ -232,7 +240,8 @@ def logical_or(image1, image2): def logical_xor(image1, image2): - """Logical XOR between two images. + """Logical XOR between two images. At least one of the images must be "1" + mode. .. code-block:: python From 2de101e02cd28d868b59e44e33ab9351d59848dd Mon Sep 17 00:00:00 2001 From: Hugo Date: Tue, 1 Jan 2019 20:42:23 +1100 Subject: [PATCH 3/4] Apply suggestions from code review Changed docstrings to be consistent Co-Authored-By: radarhere <3112309+radarhere@users.noreply.github.com> --- src/PIL/ImageChops.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/PIL/ImageChops.py b/src/PIL/ImageChops.py index 422811351..378715d24 100644 --- a/src/PIL/ImageChops.py +++ b/src/PIL/ImageChops.py @@ -54,7 +54,7 @@ def invert(image): def lighter(image1, image2): """ Compares the two images, pixel by pixel, and returns a new image containing - the lighter values. Note that at least one of the images must have mode "1". + the lighter values. At least one of the images must have mode "1". .. code-block:: python @@ -71,7 +71,7 @@ def lighter(image1, image2): def darker(image1, image2): """ Compares the two images, pixel by pixel, and returns a new image containing - the darker values. Note that at least one of the images must have mode "1". + the darker values. At least one of the images must have mode "1". .. code-block:: python @@ -88,7 +88,7 @@ def darker(image1, image2): def difference(image1, image2): """ Returns the absolute value of the pixel-by-pixel difference between the two - images. At least one of the images must be "1" mode. + images. At least one of the images must have mode "1". .. code-block:: python @@ -125,7 +125,7 @@ def multiply(image1, image2): def screen(image1, image2): """ Superimposes two inverted images on top of each other. At least one of the - images must be "1" mode. + images must have mode "1". .. code-block:: python @@ -143,7 +143,7 @@ def add(image1, image2, scale=1.0, offset=0): """ Adds two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. - At least one of the images must be "1" mode. + At least one of the images must have mode "1". .. code-block:: python @@ -161,7 +161,7 @@ def subtract(image1, image2, scale=1.0, offset=0): """ Subtracts two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. At least one of the - images must be "1" mode. + images must have mode "1". .. code-block:: python @@ -177,7 +177,7 @@ def subtract(image1, image2, scale=1.0, offset=0): def add_modulo(image1, image2): """Add two images, without clipping the result. At least one of the images - must be "1" mode. + must have mode "1". .. code-block:: python @@ -193,7 +193,7 @@ def add_modulo(image1, image2): def subtract_modulo(image1, image2): """Subtract two images, without clipping the result. At least one of the - images must be "1" mode. + images must have mode "1". .. code-block:: python @@ -208,8 +208,8 @@ def subtract_modulo(image1, image2): def logical_and(image1, image2): - """Logical AND between two images. At least one of the images must be "1" - mode. + """Logical AND between two images. At least one of the images must have + mode "1". .. code-block:: python @@ -224,8 +224,8 @@ def logical_and(image1, image2): def logical_or(image1, image2): - """Logical OR between two images. At least one of the images must be "1" - mode. + """Logical OR between two images. At least one of the images must have + mode "1". .. code-block:: python @@ -240,8 +240,8 @@ def logical_or(image1, image2): def logical_xor(image1, image2): - """Logical XOR between two images. At least one of the images must be "1" - mode. + """Logical XOR between two images. At least one of the images must have + mode "1". .. code-block:: python From ff61119f9f805061a7a0580352d200e6f047d112 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 1 Jan 2019 20:44:04 +1100 Subject: [PATCH 4/4] Changed docstring to be consistent --- src/PIL/ImageChops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PIL/ImageChops.py b/src/PIL/ImageChops.py index 378715d24..b1f71b5e7 100644 --- a/src/PIL/ImageChops.py +++ b/src/PIL/ImageChops.py @@ -108,7 +108,7 @@ def multiply(image1, image2): If you multiply an image with a solid black image, the result is black. If you multiply with a solid white image, the image is unaffected. At least - one of the images must be "1" mode. + one of the images must have mode "1". .. code-block:: python