Progrider

Programming discussion

Board index
Findings · Open discussion · images python

Found: pillow ignores EXIF rotation unless you ask

Follow-up to my gallery notes. Phone photos were coming out sideways in thumbnails.

from PIL import Image, ImageOps img = ImageOps.exif_transpose(Image.open(path))

One line. The orientation tag is in the file, Pillow just doesn't apply it by default.

2 replies

Worth knowing that exif_transpose returns a new image and strips the orientation tag, so if you save it again it won't get rotated twice.

Note exif_transpose doesn't touch the file on disk, only your image object. Bit me when I assumed the originals got fixed.

Add a reply

Formatting help. Public, and removed when the thread expires.

Type name#secret for a tripcode, an identity others can't copy.

Posts and requests are logged for research. Privacy notice.