From af94b45cbcae3d808d2b27dda06bfa68678b6c8d Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Tue, 7 May 2013 23:33:21 +0300 Subject: [PATCH] allow integer image resolution as well as rational --- PIL/TiffImagePlugin.py | 4 ++++ Tests/test_file_tiff.py | 1 + 2 files changed, 5 insertions(+) diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index b137968a8..2c6e3dd9b 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -723,6 +723,10 @@ class TiffImageFile(ImageFile.ImageFile): xres = getscalar(X_RESOLUTION, (1, 1)) yres = getscalar(Y_RESOLUTION, (1, 1)) + if xres and not isinstance(xres, tuple): + xres = (xres, 1.) + if yres and not isinstance(yres, tuple): + yres = (yres, 1.) if xres and yres: xres = xres[0] / (xres[1] or 1) yres = yres[0] / (yres[1] or 1) diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 8b53140bc..071b999dc 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -70,3 +70,4 @@ def test_xyres_tiff(): im.tag.tags[X_RESOLUTION] = (72,) im.tag.tags[Y_RESOLUTION] = (72,) im._setup() + im.info['dpi'] == (72., 72.)