mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 09:26:16 +03:00
Merge pull request #213 from mattip/master
add tests and fix for issue 212
This commit is contained in:
commit
6599df461b
|
@ -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)
|
||||
|
|
|
@ -60,4 +60,14 @@ def test_gimp_tiff():
|
|||
])
|
||||
assert_no_exception(lambda: im.load())
|
||||
|
||||
|
||||
def test_xyres_tiff():
|
||||
from PIL.TiffImagePlugin import X_RESOLUTION, Y_RESOLUTION
|
||||
file = "Tests/images/pil168.tif"
|
||||
im = Image.open(file)
|
||||
assert isinstance(im.tag.tags[X_RESOLUTION][0], tuple)
|
||||
assert isinstance(im.tag.tags[Y_RESOLUTION][0], tuple)
|
||||
#Try to read a file where X,Y_RESOLUTION are ints
|
||||
im.tag.tags[X_RESOLUTION] = (72,)
|
||||
im.tag.tags[Y_RESOLUTION] = (72,)
|
||||
im._setup()
|
||||
assert_equal(im.info['dpi'], (72., 72.))
|
||||
|
|
Loading…
Reference in New Issue
Block a user