Skip to content

fix: handle EXIF orientation for uploaded images#11362

Merged
cdrini merged 8 commits intointernetarchive:masterfrom
akramcodez:fix/author-photo-exif-rotation
Oct 29, 2025
Merged

fix: handle EXIF orientation for uploaded images#11362
cdrini merged 8 commits intointernetarchive:masterfrom
akramcodez:fix/author-photo-exif-rotation

Conversation

@akramcodez
Copy link
Contributor

Closes #11129

Description

Author photos uploaded from Wikimedia Commons were appearing rotated 90° counterclockwise.
This fix adds EXIF orientation handling to automatically correct image rotation before saving thumbnails.

Changes

Added apply_exif_orientation() function to openlibrary/coverstore/coverlib.py using PIL's ImageOps.exif_transpose() method.
This function is called in write_image() immediately after opening the image and before thumbnail generation.
It automatically reads EXIF orientation metadata, rotates the image pixels accordingly, and removes the EXIF tag to prevent future rotation issues.

The solution handles all 8 EXIF orientation values and includes proper error handling with fallback to the original image.

Screen Recording

exif-video.mov

Copilot AI review requested due to automatic review settings October 17, 2025 06:20
@github-project-automation github-project-automation bot moved this to Waiting Review/Merge from Staff in Ray's Project Oct 17, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where author photos uploaded from Wikimedia Commons were displaying rotated 90° counterclockwise by implementing EXIF orientation handling.

  • Added EXIF orientation correction using PIL's ImageOps.exif_transpose() method
  • Integrated orientation handling into the image processing pipeline before thumbnail generation
  • Included proper error handling with fallback to original image

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Oct 18, 2025
@akramcodez
Copy link
Contributor Author

PTAL @RayBB, thanks.

Copy link
Collaborator

@RayBB RayBB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working locally!

Image

@cdrini can we put this on testing?

@RayBB RayBB removed the Needs: Response Issues which require feedback from lead label Oct 29, 2025
@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Oct 29, 2025
Removed apply_exif_orientation function and integrated its logic directly into save_image.
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, thank you @akramcodez ! @RayBB tested with the sample image and with an image that doesn't need rotation.

Modified the code a bit to make this inline, since it's not a piece we'll likely need in another method.

@cdrini cdrini merged commit b932ca2 into internetarchive:master Oct 29, 2025
4 checks passed
@github-project-automation github-project-automation bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Rotating an Imported author image

4 participants