mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
Merge pull request #3998 from chadawagner/master
Fix bug in TIFF loading of BufferedReader
This commit is contained in:
commit
d96f657328
|
@ -81,6 +81,19 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
self.assertEqual(im.size, (500, 500))
|
||||
self._assert_noerr(im)
|
||||
|
||||
def test_g4_non_disk_file_object(self):
|
||||
"""Testing loading from non-disk non-BytesIO file object"""
|
||||
test_file = "Tests/images/hopper_g4_500.tif"
|
||||
s = io.BytesIO()
|
||||
with open(test_file, "rb") as f:
|
||||
s.write(f.read())
|
||||
s.seek(0)
|
||||
r = io.BufferedReader(s)
|
||||
im = Image.open(r)
|
||||
|
||||
self.assertEqual(im.size, (500, 500))
|
||||
self._assert_noerr(im)
|
||||
|
||||
def test_g4_eq_png(self):
|
||||
""" Checking that we're actually getting the data that we expect"""
|
||||
png = Image.open("Tests/images/hopper_bw_500.png")
|
||||
|
|
|
@ -1164,7 +1164,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
if DEBUG:
|
||||
print("have getvalue. just sending in a string from getvalue")
|
||||
n, err = decoder.decode(self.fp.getvalue())
|
||||
elif hasattr(self.fp, "fileno"):
|
||||
elif fp:
|
||||
# we've got a actual file on disk, pass in the fp.
|
||||
if DEBUG:
|
||||
print("have fileno, calling fileno version of the decoder.")
|
||||
|
@ -1175,6 +1175,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
# we have something else.
|
||||
if DEBUG:
|
||||
print("don't have fileno or getvalue. just reading")
|
||||
self.fp.seek(0)
|
||||
# UNDONE -- so much for that buffer size thing.
|
||||
n, err = decoder.decode(self.fp.read())
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user