Menu

Why your OCR sees ID photos sideways: EXIF orientation, and fixing it with Pillow
📰

Why your OCR sees ID photos sideways: EXIF orientation, and fixing it with Pillow

DEV Community: computervision·Ali Ahmed·about 2 hours ago
#No4M8Qpk
Long article (697 words) — no AI summary yet.
Reading 0:00
15s threshold

A phone held upright doesn't rotate the pixels it saves. It stores the image in the camera sensor's orientation , often landscape, and adds an EXIF Orientation tag (value 6, for example, means "rotate 90° clockwise to display"). Photo viewers and browsers apply the tag, so the user sees an upright document. OCR and face detection read the raw pixels , so they get the document sideways : text lines run vertically and recognition quality collapses. The fix is one line with Pillow, ImageOps.exif_transpose(img) , applied before anything else touches the image. It has to come first, because re-encoding or stripping metadata before applying it loses the orientation permanently .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.