Allow 1 mode images to be inverted

This commit is contained in:
Andrew Murray 2022-02-08 09:12:01 +11:00
parent f018518e24
commit ecb64fe210
2 changed files with 2 additions and 1 deletions

View File

@ -63,6 +63,7 @@ def test_sanity():
ImageOps.grayscale(hopper("L")) ImageOps.grayscale(hopper("L"))
ImageOps.grayscale(hopper("RGB")) ImageOps.grayscale(hopper("RGB"))
ImageOps.invert(hopper("1"))
ImageOps.invert(hopper("L")) ImageOps.invert(hopper("L"))
ImageOps.invert(hopper("RGB")) ImageOps.invert(hopper("RGB"))

View File

@ -523,7 +523,7 @@ def invert(image):
lut = [] lut = []
for i in range(256): for i in range(256):
lut.append(255 - i) lut.append(255 - i)
return _lut(image, lut) return image.point(lut) if image.mode == "1" else _lut(image, lut)
def mirror(image): def mirror(image):