mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-15 18:52:19 +03:00
a test that fails for images with integer resolution
This commit is contained in:
parent
eee43319bb
commit
5ca04bb728
|
@ -615,7 +615,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
return pixel
|
return pixel
|
||||||
|
|
||||||
self.load_prepare()
|
self.load_prepare()
|
||||||
|
|
||||||
if not len(self.tile) == 1:
|
if not len(self.tile) == 1:
|
||||||
raise IOError("Not exactly one tile")
|
raise IOError("Not exactly one tile")
|
||||||
|
|
||||||
|
@ -635,7 +635,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
#
|
#
|
||||||
# Rearranging for supporting byteio items, since they have a fileno
|
# Rearranging for supporting byteio items, since they have a fileno
|
||||||
# that returns an IOError if there's no underlying fp. Easier to deal
|
# that returns an IOError if there's no underlying fp. Easier to deal
|
||||||
# with here by reordering.
|
# with here by reordering.
|
||||||
if Image.DEBUG:
|
if Image.DEBUG:
|
||||||
print ("have getvalue. just sending in a string from getvalue")
|
print ("have getvalue. just sending in a string from getvalue")
|
||||||
n,e = d.decode(self.fp.getvalue())
|
n,e = d.decode(self.fp.getvalue())
|
||||||
|
@ -649,10 +649,10 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
# we have something else.
|
# we have something else.
|
||||||
if Image.DEBUG:
|
if Image.DEBUG:
|
||||||
print ("don't have fileno or getvalue. just reading")
|
print ("don't have fileno or getvalue. just reading")
|
||||||
# UNDONE -- so much for that buffer size thing.
|
# UNDONE -- so much for that buffer size thing.
|
||||||
n, e = d.decode(self.fp.read())
|
n, e = d.decode(self.fp.read())
|
||||||
|
|
||||||
|
|
||||||
self.tile = []
|
self.tile = []
|
||||||
self.readonly = 0
|
self.readonly = 0
|
||||||
self.fp = None # might be shared
|
self.fp = None # might be shared
|
||||||
|
@ -750,19 +750,19 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
# Decoder expects entire file as one tile.
|
# Decoder expects entire file as one tile.
|
||||||
# There's a buffer size limit in load (64k)
|
# There's a buffer size limit in load (64k)
|
||||||
# so large g4 images will fail if we use that
|
# so large g4 images will fail if we use that
|
||||||
# function.
|
# function.
|
||||||
#
|
#
|
||||||
# Setup the one tile for the whole image, then
|
# Setup the one tile for the whole image, then
|
||||||
# replace the existing load function with our
|
# replace the existing load function with our
|
||||||
# _load_libtiff function.
|
# _load_libtiff function.
|
||||||
|
|
||||||
self.load = self._load_libtiff
|
self.load = self._load_libtiff
|
||||||
|
|
||||||
# To be nice on memory footprint, if there's a
|
# To be nice on memory footprint, if there's a
|
||||||
# file descriptor, use that instead of reading
|
# file descriptor, use that instead of reading
|
||||||
# into a string in python.
|
# into a string in python.
|
||||||
|
|
||||||
# libtiff closes the file descriptor, so pass in a dup.
|
# libtiff closes the file descriptor, so pass in a dup.
|
||||||
try:
|
try:
|
||||||
fp = hasattr(self.fp, "fileno") and os.dup(self.fp.fileno())
|
fp = hasattr(self.fp, "fileno") and os.dup(self.fp.fileno())
|
||||||
except IOError:
|
except IOError:
|
||||||
|
@ -990,7 +990,7 @@ def _save(im, fp, filename):
|
||||||
if type(v) == str:
|
if type(v) == str:
|
||||||
atts[k] = v
|
atts[k] = v
|
||||||
continue
|
continue
|
||||||
|
|
||||||
except:
|
except:
|
||||||
# if we don't have an ifd here, just punt.
|
# if we don't have an ifd here, just punt.
|
||||||
pass
|
pass
|
||||||
|
@ -1007,7 +1007,7 @@ def _save(im, fp, filename):
|
||||||
break
|
break
|
||||||
if s < 0:
|
if s < 0:
|
||||||
raise IOError("encoder error %d when writing image file" % s)
|
raise IOError("encoder error %d when writing image file" % s)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
offset = ifd.save(fp)
|
offset = ifd.save(fp)
|
||||||
|
|
||||||
|
|
|
@ -60,4 +60,13 @@ def test_gimp_tiff():
|
||||||
])
|
])
|
||||||
assert_no_exception(lambda: im.load())
|
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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user