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

Apply orientation transformation based on EXIF data #1912

Merged
merged 2 commits into from
Jul 7, 2022

Conversation

bemyak
Copy link
Contributor

@bemyak bemyak commented Jun 26, 2022

Some images (especially photos) are stored with incorrect orientation. There is a EXIF metadata attached, so browsers and image viewers know how to display it properly.

Unfortunately, when applying transformations, this metadata isn't copied (see image-rs/image#1045 (comment)), so the only way to fix it is to apply the corresponding transform on the Zola's side.


Sanity check:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

  • Are you doing the PR on the next branch?
  • [?] Have you created/updated the relevant documentation page(s)? (Should I?)

@bemyak bemyak force-pushed the apply-exif-transform branch from cf7accb to a85d271 Compare June 26, 2022 14:04
@bemyak
Copy link
Contributor Author

bemyak commented Jun 26, 2022

Just to clarify: all 8 new images are differently oriented, but they have the correct EXIF tag set, so the browser displays them properly. The issue can be reproduced if you try to resize_image any of them (except the first one, it has no rotation).

Copy link
Collaborator

@Keats Keats left a comment

Choose a reason for hiding this comment

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

That seems good. The GH preview shows all image with the top left being red, can you add a detail in one of the test what is the exif data in each?

@bemyak bemyak force-pushed the apply-exif-transform branch from a85d271 to d041b77 Compare July 4, 2022 21:49
@bemyak
Copy link
Contributor Author

bemyak commented Jul 4, 2022

The number in an image filename indicates the value of the Orientation tag. For exif_0.jpg the tag is not set. I've added the corresponding descriptions.

For reference, the image description is taken from an output of this command:

$ exiftool -Orientation exif_5.jpg
Orientation                     : Mirror horizontal and rotate 270 CW

You can get the raw value like this:

$ exiftool -b -Orientation exif_5.jpg
5

@bemyak bemyak requested a review from Keats July 4, 2022 21:52
Copy link
Collaborator

@Keats Keats left a comment

Choose a reason for hiding this comment

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

Small nits.
Do you have an example site where Zola was displaying things incorrectly after an op? Just to easily try this branch somewhere

components/imageproc/src/lib.rs Outdated Show resolved Hide resolved
components/imageproc/src/lib.rs Outdated Show resolved Hide resolved
@bemyak bemyak force-pushed the apply-exif-transform branch from 1134c6c to ce83e08 Compare July 6, 2022 20:36
@bemyak
Copy link
Contributor Author

bemyak commented Jul 6, 2022

Do you have an example site where Zola was displaying things incorrectly after an op? Just to easily try this branch somewhere

Yep, you can clone this, and then open /ru/finland/tuomarilanrinne/ url. The first image (with a baby) is oriented incorrectly, but if you click on it, the original will be opened, which didn't pass the transformation, so it displays correctly.

To build the blog you'll probably need git-lfs installed and zola next, it doesn't build on stable because of #1904

Also when trying different versions remember to delete static/processed_images dir.

@bemyak
Copy link
Contributor Author

bemyak commented Jul 6, 2022

Alternatively, you can just use the test images from this PR, it'll probably be faster. The blog is pretty heavy.

@bemyak bemyak requested a review from Keats July 6, 2022 21:02
@bemyak bemyak force-pushed the apply-exif-transform branch from ce83e08 to 586a7ff Compare July 6, 2022 21:03
Copy link
Collaborator

@Keats Keats left a comment

Choose a reason for hiding this comment

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

Perfect, thanks!

@Keats Keats merged commit 065e8e6 into getzola:next Jul 7, 2022
theowenyoung added a commit to theowenyoung/zola that referenced this pull request Jul 8, 2022
* 'next' of github.com:getzola/zola:
  Apply orientation transformation based on EXIF data (getzola#1912)
  Stop printing invalid files in dirs
  fix windows EOL in markdown files (getzola#1911)
  Properly escape anchor names (getzola#1908)
  Allow new lines before anchor (getzola#1905)
  Fix incorrect documentation for syntax directory (getzola#1901)
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.

2 participants