Skip to content

XResolution is not a tuple - #10360

Merged
radarhere merged 2 commits into
python-pillow:mainfrom
radarhere:dpi_tuple
Oct 30, 2026
Merged

radarhere merged 2 commits into
python-pillow:mainfrom
radarhere:dpi_tuple

Conversation

@radarhere

@radarhere radarhere commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

#2449 added

x_resolution = self._getexif()[0x011A]
self.info["dpi"] = x_resolution[0] / x_resolution[1]

to handle Tests/images/photoshop-200dpi.jpg.

However, https://web.archive.org/web/20230619074419/https://www.awaresystems.be/imaging/tiff/tifftags/xresolution.html says that this RATIONAL tag has a count of 1, not 2.

Exif doesn't even report the test image as returning a tuple anymore.

>>> from PIL import Image
>>> im = Image.open("Tests/images/photoshop-200dpi.jpg")
>>> im.getexif()[0x011A]
200.0

When did this change? #4637, which

changes RATIONALs to be read as IFDRationals, instead of a tuple with (numerator, denominator).

So support for XResolution tuples is no longer required, and neither do we need to catch the ZeroDivisionError from #2667

@radarhere radarhere added the JPEG label Oct 29, 2026
@radarhere
radarhere merged commit 2b45d1e into python-pillow:main Oct 30, 2026
51 checks passed
@radarhere
radarhere deleted the dpi_tuple branch October 30, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant