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
DPI is a tuple #2472
DPI is a tuple #2472
Conversation
PIL/JpegImagePlugin.py
Outdated
x_resolution = self._getexif()[0x011A] | ||
self.info["dpi"] = x_resolution[0] / x_resolution[1] | ||
exif = self._getexif() | ||
x_resolution = exif[0x011A] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could fail with a keyerror?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically, yes. I'll wrap in another try/except later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, but see below.
It's better to check the spec before implementing things... http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html says:
And http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html gives these for resolution unit:
So I'll update this again:
|
@hugovk , you happy with this? |
@wiredfool Yes. Feel free to squash and merge if you'd like to tidy up the commits. |
someone is screen shotting on a high dpi monitor... |
Yes, that was a surprisingly large image! |
Fix merged PR #2449, re: 977f319#commitcomment-21546844
DPI should be an (xres, yres) tuple.
Confirmed in code and docs:
Note: one test image (Tests/images/exif_gps.jpg) only has an X value, and so raised exceptions, so if there's no Y value, use the X twice.