allow integer image resolution as well as rational

This commit is contained in:
Matti Picus 2013-05-07 23:33:21 +03:00
parent 5ca04bb728
commit af94b45cbc
2 changed files with 5 additions and 0 deletions

View File

@ -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)

View File

@ -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.)