ImageOps Official Documentation:
https://pillow.readthedocs.io/en/stable/reference/ImageOps.html
You can use ImageOps to quickly flip, mirror, and invert images.
Examples:
from PIL import Image, ImageOps
cat = Image.open('silly_cat.jpg')
cat_mir = ImageOps.mirror(cat)
cat_flip = ImageOps.flip(cat)
cat_inv = ImageOps.invert(cat)
cat_flip.save('cat_flip.jpg')
cat_inv.save('cat_inv.jpg')
cat_mir.save('cat_mir.jpg')
Notice that ImageOps needs to be imported along with Image.
These functions return a new image, so avoid this error:
# Doesn't do anything (cat is unchanged) ImageOps.mirror(cat) # Does something (creates output object) output = ImageOps.mirror(cat)
Original Image

Mirrored

Flipped

Inverted

ImageOps also has some other useful functions that you can check out in the documentation link at the top:
- Several handy resizing methods
- Add border (expand function)
- Crop a border
- Posterize (reduce color resolution)