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

[FIX] tools: fix orientation of image with EXIF orientation tag #37448

Closed
wants to merge 1 commit into from

Conversation

seb-odoo
Copy link
Contributor

Before this commit, some images would display incorrectly orientated.

This typically happens for images taken from a non-standard orientation
by some phones or other devices that are able to report orientation.

The specified transposition is applied to the image before all other
operations, because all of them expect the image to be in its final
orientation, which is the case only when the first row of pixels is the top
of the image and the first column of pixels is the left of the image.

Moreover the EXIF tags will not be kept when the image is later saved, so
the transposition has to be done to ensure the final image is correctly
orientated.

@seb-odoo seb-odoo added RD research & development, internal work Website labels Sep 25, 2019
@seb-odoo seb-odoo self-assigned this Sep 25, 2019
@robodoo robodoo added CI 🤖 Robodoo has seen passing statuses seen 🙂 labels Sep 25, 2019
@robodoo robodoo removed the CI 🤖 Robodoo has seen passing statuses label Sep 26, 2019
@seb-odoo seb-odoo marked this pull request as ready for review September 26, 2019 22:25
@seb-odoo
Copy link
Contributor Author

Note that since python-pillow/Pillow#4063 Pillow seems to do it by default, but only for TIFF files. Might need to add an ugly hack to avoid doing the job when Pillow already does it if we want to support multiple versions at the same time.

@seb-odoo
Copy link
Contributor Author

@mart-e I would like your opinion on this PR and also the above comment.

@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Sep 26, 2019
@mart-e
Copy link
Contributor

mart-e commented Sep 27, 2019

Might need to add an ugly hack to avoid doing the job when Pillow already does it if we want to support multiple versions at the same time.

We do that from time to time, it is acceptable.

(still need to review the patch)

Copy link
Contributor

@mart-e mart-e left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed report and the test.
Could be good to mention https://magnushoff.com/articles/jpeg-orientation/ as the description of the issue in the commit message.

mart-e added a commit to odoo-dev/odoo that referenced this pull request Oct 8, 2019
https://packages.debian.org/buster/python-pil
As of today, python-pillow is at 5.4 in the latest debian release

This allows to deprecate the older versions progessively

Newer versions have new features like the exif_transpose method in 6.0
as discussed at odoo#37448
@seb-odoo
Copy link
Contributor Author

seb-odoo commented Oct 8, 2019

TODO:

if hasattr(ImageOps, 'exif_transpose'): # added in pillow 6.0 return ImageOps.exif_transpose(image)

maybe also add a condition on type jpeg for the condition on getexif

robodoo pushed a commit that referenced this pull request Oct 9, 2019
https://packages.debian.org/buster/python-pil
As of today, python-pillow is at 5.4 in the latest debian release

This allows to deprecate the older versions progessively

Newer versions have new features like the exif_transpose method in 6.0
as discussed at #37448

closes #38189

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Oct 9, 2019
https://packages.debian.org/buster/python-pil
As of today, python-pillow is at 5.4 in the latest debian release

This allows to deprecate the older versions progessively

Newer versions have new features like the exif_transpose method in 6.0
as discussed at odoo#37448

X-original-commit: 4ad7a99
@seb-odoo
Copy link
Contributor Author

seb-odoo commented Oct 9, 2019

self todo also retarget to 13 since 12.4 is dead

robodoo pushed a commit that referenced this pull request Oct 9, 2019
https://packages.debian.org/buster/python-pil
As of today, python-pillow is at 5.4 in the latest debian release

This allows to deprecate the older versions progessively

Newer versions have new features like the exif_transpose method in 6.0
as discussed at #37448

closes #38245

X-original-commit: 4ad7a99
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
@seb-odoo seb-odoo changed the base branch from saas-12.4 to 13.0 October 11, 2019 14:18
@robodoo robodoo added CI 🤖 Robodoo has seen passing statuses and removed CI 🤖 Robodoo has seen passing statuses labels Oct 11, 2019
Before this commit, some images would display incorrectly orientated.

This typically happens for images taken from a non-standard orientation
by some phones or other devices that are able to report orientation.

The specified transposition is applied to the image before all other
operations, because all of them expect the image to be in its final
orientation, which is the case only when the first row of pixels is the top
of the image and the first column of pixels is the left of the image.

Moreover the EXIF tags will not be kept when the image is later saved, so
the transposition has to be done to ensure the final image is correctly
orientated.
@robodoo robodoo removed the CI 🤖 Robodoo has seen passing statuses label Oct 11, 2019
@seb-odoo
Copy link
Contributor Author

I had to make some adaptations: mainly extracting image_fix_orientation out of base64_to_image because it would lose the original format of the image in the process.

Hopefully this should be good now, rebased, re-targeted, and added the Pillow 6 function.

I don't really like adding a link in the commit message as it could always become broken at some point. I think I have commented enough, and this PR will be linked anyway.

@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Oct 11, 2019
@seb-odoo
Copy link
Contributor Author

@robodoo r+

robodoo pushed a commit that referenced this pull request Oct 14, 2019
Before this commit, some images would display incorrectly orientated.

This typically happens for images taken from a non-standard orientation
by some phones or other devices that are able to report orientation.

The specified transposition is applied to the image before all other
operations, because all of them expect the image to be in its final
orientation, which is the case only when the first row of pixels is the top
of the image and the first column of pixels is the left of the image.

Moreover the EXIF tags will not be kept when the image is later saved, so
the transposition has to be done to ensure the final image is correctly
orientated.

closes #37448

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
@robodoo robodoo added error 🙅 and removed CI 🤖 Robodoo has seen passing statuses merging 👷 labels Oct 14, 2019
@robodoo
Copy link
Contributor

robodoo commented Oct 14, 2019

Staging failed: ci/runbot on 26f631a6ad9b334f1a8f061c6d45a1192ac377db (view more at http://runbot.odoo.com/runbot/build/651601)

@mart-e
Copy link
Contributor

mart-e commented Oct 14, 2019

robodoo retry

@robodoo
Copy link
Contributor

robodoo commented Oct 14, 2019

Merged at 0f8e132, thanks!

@seb-odoo seb-odoo deleted the saas-12.4-fix-img-rotate-seb branch October 14, 2019 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
13.0 CI 🤖 Robodoo has seen passing statuses RD research & development, internal work Website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants