mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-20 12:14:46 +03:00
Add support for 1-bit images to ImageOps.invert()
This commit is contained in:
parent
f018518e24
commit
9a78e37936
|
@ -520,6 +520,11 @@ def invert(image):
|
||||||
:param image: The image to invert.
|
:param image: The image to invert.
|
||||||
:return: An image.
|
:return: An image.
|
||||||
"""
|
"""
|
||||||
|
# Special case for 1-bit images using python translate() method
|
||||||
|
if image.mode == '1':
|
||||||
|
lut = bytearray(range(255,-1,-1))
|
||||||
|
return Image.frombuffer('1',image.size,image.tobytes().translate(lut))
|
||||||
|
|
||||||
lut = []
|
lut = []
|
||||||
for i in range(256):
|
for i in range(256):
|
||||||
lut.append(255 - i)
|
lut.append(255 - i)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user