Python, Pillow: Flip image

Posted: 2019-06-25 / Tags: Python, Pillow, Image Processing
Sponsored Link


The ImageOps module of the Python image processing library Pillow(PIL) provides flip() to flip the image upside down (vertically) and mirror() to flip the left and right (horizontally).

Please refer to the following post for installation and basic usage of Pillow(PIL).

Use the rotate() method of the Image module to rotate the image.

See the following post for image rotation with OpenCV, NumPy.

Sample code

Load the image and call flip() or mirror().

from PIL import Image, ImageOps

im ='data/src/lena.jpg')


im_flip = ImageOps.flip(im)'data/dst/lena_flip.jpg', quality=95)

Pillow flip lena

im_mirror = ImageOps.mirror(im)'data/dst/lena_mirror.jpg', quality=95)

Pillow mirror lena

Sponsored Link

Related Categories

Related Posts