In this tutorial, we will use an example to introduce how to useĀ ImageOps.invert() to invert image color in python pillow.
1.Open an image
from PIL import Image, ImageOps im = Image.open('data/src/horse.png').convert('RGB')
2.Invert image color usingĀ ImageOps.invert()
im_invert = ImageOps.invert(im)
3.Save inverted image
im_invert.save('data/dst/horse_invert.png')
Run this code, you will see this inverted image: