From bb4ce0b94a71ed3b45a134ed61ef844189c9e648 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 8 Feb 2022 07:39:24 +1100 Subject: [PATCH] Support 1 mode images in several methods --- Tests/test_imageops.py | 5 +++++ src/PIL/ImageOps.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index 6aa1cf35edf..71393871cb0 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -22,6 +22,7 @@ def getmesh(self, im): def test_sanity(): + ImageOps.autocontrast(hopper("1")) ImageOps.autocontrast(hopper("L")) ImageOps.autocontrast(hopper("RGB")) @@ -46,6 +47,7 @@ def test_sanity(): ImageOps.deform(hopper("L"), deformer) ImageOps.deform(hopper("RGB"), deformer) + ImageOps.equalize(hopper("1")) ImageOps.equalize(hopper("L")) ImageOps.equalize(hopper("RGB")) @@ -63,15 +65,18 @@ def test_sanity(): ImageOps.grayscale(hopper("L")) ImageOps.grayscale(hopper("RGB")) + ImageOps.invert(hopper("1")) ImageOps.invert(hopper("L")) ImageOps.invert(hopper("RGB")) ImageOps.mirror(hopper("L")) ImageOps.mirror(hopper("RGB")) + ImageOps.posterize(hopper("1"), 4) ImageOps.posterize(hopper("L"), 4) ImageOps.posterize(hopper("RGB"), 4) + ImageOps.solarize(hopper("1")) ImageOps.solarize(hopper("L")) ImageOps.solarize(hopper("RGB")) diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index b170e9d8cc9..e0c2014969e 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -50,7 +50,7 @@ def _lut(image, lut): if image.mode == "P": # FIXME: apply to lookup table, not image data raise NotImplementedError("mode P support coming soon") - elif image.mode in ("L", "RGB"): + elif image.mode in ("1", "L", "RGB"): if image.mode == "RGB" and len(lut) == 256: lut = lut + lut + lut return image.point(lut)