Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up auto_orient logic #138

Closed
wants to merge 2 commits into from
Closed

Clean up auto_orient logic #138

wants to merge 2 commits into from

Conversation

Stormheg
Copy link
Member

Move away from bespoke logic and rely on ImageOps.exif_transpose(). This method works much better than our own as it also supports reading XMP metadata instead of just EXIF.

In addition, it also removes the orientation metadata from the transposed image.

This method was added in Pillow 6.0.0.
See: https://github.com/python-pillow/Pillow/blob/28c173f8d4767c7f6dd22dc840117fe641f4d3ee/docs/releasenotes/6.0.0.rst#added-imageopsexif_transpose

This fixes #137 in the process by removing stale orientation metadata.

Move away from bespoke logic and rely on `ImageOps.exif_transpose()`.
This method works much better than our own as it also supports reading
XMP metadata instead of just EXIF.

In addition, it also removes the orientation metadata from the transposed image.

This method was added in Pillow 6.0.0.
See: https://github.com/python-pillow/Pillow/blob/28c173f8d4767c7f6dd22dc840117fe641f4d3ee/docs/releasenotes/6.0.0.rst#added-imageopsexif_transpose

This fixes #137 in the process by removing stale orientation metadata.
@Stormheg
Copy link
Member Author

Removing code feels so good 😛
image

Comment on lines +32 to +36
def _PIL_ImageOps():
import PIL.ImageOps

return PIL.ImageOps

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm following the same pattern as the code above. Not sure if it is needed though, I assume the indirection is to defer loading large modules? Not sure if that applies to PIL.ImageOps

To prove that orientation metadata is removed, as that is part of the
expected behaviour now.
@Stormheg
Copy link
Member Author

As it turns out, a very similar change is proposed in #136. Closing this in favour of that PR!

@Stormheg Stormheg closed this Nov 19, 2023
@zerolab zerolab deleted the fix/clean-up-auto-orient branch November 20, 2023 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AVIF image saved with incorrect EXIF orientation metadata after calling auto_orient
1 participant