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

[FW][FIX] tools: prevent pillow 7.0 bug on exif_transpose #65595

Closed

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Feb 5, 2021

On odoo.sh, in some circumstances, when uploading an image as attachment
in odoo leads to a blank image thumbnail. The same image was
successfully uploaded in the same odoo version on runbot instance.

After some investigations, it appears that the issue comes from the
python-pillow version used. A few bugs exists [0,1,2] in python-pillow
7.0.0 (packaged in ubuntu Focal) that are now fixed in version 8.1.0
[3,4,5] (packaged in Debian and specified in Odoo requirements.txt),
that causes the ImageOps.exif_transpose method to fail.

The present issue can be considered as a corner case as only images with
particular exif tags cause the issue.

The present fix is a simple workaround by first checking the presence of
the orientation tag and using it, we can avoid a call to the
exif_transpose method.

opw-2369166

[0] python-pillow/Pillow#4346
[1] python-pillow/Pillow#3973
[2] python-pillow/Pillow#4238
[3] python-pillow/Pillow#4637
[4] python-pillow/Pillow#3980
[5] python-pillow/Pillow#4009

Forward-Port-Of: #65584

On odoo.sh, in some circumstances, when uploading an image as attachment
in odoo leads to a blank image thumbnail. The same image was
successfully uploaded in the same odoo version on runbot instance.

After some investigations, it appears that the issue comes from the
python-pillow version used. A few bugs exists [0,1,2] in python-pillow
7.0.0 (packaged in ubuntu Focal) that are now fixed in version 8.1.0
[3,4,5] (packaged in Debian and specified in Odoo requirements.txt),
that causes the `ImageOps.exif_transpose` method to fail.

The present issue can be considered as a corner case as only images with
particular exif tags cause the issue.

The present fix is a simple workaround by first checking the presence of
the orientation tag and using it, we can avoid a call to the
`exif_transpose` method.

opw-2369166

[0] python-pillow/Pillow#4346
[1] python-pillow/Pillow#3973
[2] python-pillow/Pillow#4238
[3] python-pillow/Pillow#4637
[4] python-pillow/Pillow#3980
[5] python-pillow/Pillow#4009

X-original-commit: b83c48d
@fw-bot fw-bot requested review from a team as code owners February 5, 2021 11:10
@robodoo robodoo added the forwardport This PR was created by @fw-bot label Feb 5, 2021
@robodoo
Copy link
Contributor

robodoo commented Feb 5, 2021

@fw-bot
Copy link
Contributor Author

fw-bot commented Feb 5, 2021

This PR targets 14.0 and is part of the forward-port chain. Further PRs will be created up to master.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Feb 5, 2021
@xmo-odoo
Copy link
Collaborator

xmo-odoo commented Feb 5, 2021

@d-fence doesn't that essentially remove the use of Pillow's exif_transpose? I would expect the exif_transpose was an "optimisation" of sorts to avoid calling into our own code (if anything the Pillow version is worse as it will copy() the image even if transposition is not necessary, it will also update the EXIF metadata which we don't do and may lead to double-transposition, though the docstring states we'll save the image without EXIF data so the issue is probably limited).

At that point we might as well just remove the call to Pillow's.

@seb-odoo
Copy link
Contributor

seb-odoo commented Feb 5, 2021

it will also update the EXIF metadata which we don't do and may lead to double-transposition, though the docstring states we'll save the image without EXIF data so the issue is probably limited).

It's actually because we don't save the EXIF that we don't bother removing it, but the Pillow approach is correct here. If the orientation of the raw data has been changed, the corresponding EXIF should be removed to avoid double-transposition potential issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants