[go: up one dir, main page]

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

Respect EXIF orientation #614

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

amras0000
Copy link
@amras0000 amras0000 commented Nov 8, 2023

This PR checks EXIF orientation. Addresses #470.

Method

Calls to ffprobe are replaced with exiftool (supported file formats: https://exiftool.org/TagNames/)
exiftool is capable of getting the metadata we want for static images and video, and gives us access to an image's Orientation.

Alternative

This branch is heavily inspired by skybldev's work here: https://github.com/rr-/szurubooru/pull/499.
Differences:

  • This PR has a smaller scope - only orientation is checked, no other features are added.
  • skybldev's fork uses the exif python library alongside ffprobe. This PR uses only exiftool.

Limitations

  • This PR is still missing a migration to regenerate existing images + thumbnails.
  • This PR is still missing unit tests for EXIF images. [added in 4ad9000]

exiftool presents similar data to ffprobe, so it may be used as a replacement.

notably, this change will give us access to the "Orientation" tag,
 which ffprobe does not provide.

[server] install exiftool on the docker image
[server] replace Image._reload_info's implementation with a call to exiftool
[server] remove unused Image.frames property; replace with Image.duration
This change resolves https://github.com/rr-/szurubooru/issues/470
As well as correcting a related issue with thumbnail rotation.

Based on the EXIF Orientation data,
 we correctly size the scaled image in the post view,
 and rotate the image before creating its thumbnail.
PIL provides built-in support for transposing images
 based on EXIF Orientation.

This change adds that call.
Raise an exception when exiftool provides a Warning or Error,
 which usually indicates a corrupted file.
This exception is handled by the allow_broken_uploads setting.
The test creates a new post, containing a known image
 which has been rotated 90 degrees.

It then checks:
 - the size of the canvas
 - the size of the thumbnail
 - if the image is searchable using non-exif data
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.

1 participant