Repository navigation
DPI is a tuple - #2472
DPI is a tuple#2472
Conversation
| 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.
This could fail with a keyerror?
There was a problem hiding this comment.
Theoretically, yes. I'll wrap in another try/except later.
|
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! |
#10334 is poised to start reading Y resolution again, in case anyone here would like to weigh in. |

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.