Skip to content

Commit ecb64fe

Browse files
committed
Allow 1 mode images to be inverted
1 parent f018518 commit ecb64fe

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Tests/test_imageops.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def test_sanity():
6363
ImageOps.grayscale(hopper("L"))
6464
ImageOps.grayscale(hopper("RGB"))
6565

66+
ImageOps.invert(hopper("1"))
6667
ImageOps.invert(hopper("L"))
6768
ImageOps.invert(hopper("RGB"))
6869

src/PIL/ImageOps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def invert(image):
523523
lut = []
524524
for i in range(256):
525525
lut.append(255 - i)
526-
return _lut(image, lut)
526+
return image.point(lut) if image.mode == "1" else _lut(image, lut)
527527

528528

529529
def mirror(image):

0 commit comments

Comments
 (0)