Merge pull request #4512 from hugovk/fix-png-seek

Fix PNG seek
This commit is contained in:
Hugo van Kemenade 2020-04-02 10:43:43 +03:00 committed by GitHub
commit e9afb39534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -629,6 +629,14 @@ class TestFilePng:
with Image.open(test_file) as reloaded:
assert reloaded.info["exif"] == b"Exif\x00\x00exifstring"
def test_tell(self, tmp_path):
with Image.open(TEST_PNG_FILE) as im:
assert im.tell() == 0
def test_seek(self, tmp_path):
with Image.open(TEST_PNG_FILE) as im:
im.seek(0)
@pytest.mark.skipif(is_win32(), reason="Requires Unix or macOS")
@skip_unless_feature("zlib")

View File

@ -636,6 +636,7 @@ class PngImageFile(ImageFile.ImageFile):
if self.fp.read(8) != _MAGIC:
raise SyntaxError("not a PNG file")
self.__fp = self.fp
self.__frame = 0
#
# Parse headers up to the first IDAT or fDAT chunk