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

Exif writing fixes: Rational boundaries and signed/unsigned types #3980

Merged
merged 9 commits into from Dec 31, 2019

Conversation

kkopachev
Copy link
Contributor

@kkopachev kkopachev commented Jul 19, 2019

Related: #3973.

Changes proposed in this pull request:

@radarhere radarhere changed the title [WIP] Exif wriing fixes [WIP] Exif writing fixes Jul 21, 2019
@radarhere radarhere mentioned this pull request Jul 26, 2019
@radarhere radarhere mentioned this pull request Aug 17, 2019
@kkopachev kkopachev changed the title [WIP] Exif writing fixes Exif writing fixes: Rational boundaries and signed/unsigned types Aug 28, 2019
@kkopachev
Copy link
Contributor Author

I am totally dropping the ball at this one.
I am not really able to come up with something working and elegant in terms of writing IFDs/sub-IFDs.
So let's merge this as is, at least some improvement which can be incorporated in next release.

This seems to fix #4037. I didn't add very specific test case for it; it's kind of covered by same condition for RATIONAL/STRATIONAL tests. Let me know if I should add a specific test.

kkopachev and others added 2 commits August 29, 2019 09:06
Corrected short and long range checks
# Conflicts:
#	Tests/test_file_tiff_metadata.py
@kkopachev
Copy link
Contributor Author

Let me know, if you prefer this rebased/squashed.

@radarhere radarhere added the Exif label Aug 30, 2019
original[k] = tuple(
IFDRational(*_limit_rational(elt, 2 ** 31)) for elt in v
)

Copy link
Member

Choose a reason for hiding this comment

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

Why remove this part of the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems disfunctional and wrong.
The fact that Pillow used to incorrectly limit unsigned rationals to 2**31, does not need to be validated. TIFF allows for rationals to be up to 2**32. If original file contained bigger (but still valid) value, then it has to be the same when Pillow saves it.

@radarhere radarhere merged commit 066cc1b into python-pillow:master Dec 31, 2019
@kkopachev kkopachev deleted the exif-writing-fixes branch January 6, 2020 22:00
d-fence added a commit to odoo-dev/odoo that referenced this pull request 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
robodoo pushed a commit to odoo/odoo that referenced this pull request 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

closes #65584

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request 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

X-original-commit: b83c48d
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request 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

X-original-commit: b83c48d
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request 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

X-original-commit: b83c48d
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request 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

X-original-commit: b83c48d
@radarhere radarhere moved this from New Issues to Done in Pillow Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Pillow
  
Done
Development

Successfully merging this pull request may close these issues.

EXIF tobytes: ushort format requires 0 <= number <= (0x7fff * 2 + 1)
2 participants