From 8b06fa9a2183eede2fdf9ebeb1e9dc43f3f1ba1e Mon Sep 17 00:00:00 2001 From: Hugo Date: Tue, 11 Apr 2017 14:07:31 +0300 Subject: [PATCH] Fix for file with DPI in EXIF but not metadata, and XResolution is an int rather than tuple --- PIL/JpegImagePlugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py index 22ac2eaba..bb2816c13 100644 --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -123,7 +123,10 @@ def APP(self, marker): try: resolution_unit = exif[0x0128] x_resolution = exif[0x011A] - dpi = x_resolution[0] / x_resolution[1] + try: + dpi = x_resolution[0] / x_resolution[1] + except TypeError: + dpi = x_resolution if resolution_unit == 3: # cm # 1 dpcm = 2.54 dpi dpi *= 2.54