Skip to content

Commit

Permalink
Merge pull request #4512 from hugovk/fix-png-seek
Browse files Browse the repository at this point in the history
Fix PNG seek
  • Loading branch information
hugovk committed Apr 2, 2020
2 parents 0a77f73 + 2e9030d commit e9afb39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Tests/test_file_png.py
Expand Up @@ -629,6 +629,14 @@ def test_exif_argument(self, tmp_path):
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")
Expand Down
1 change: 1 addition & 0 deletions src/PIL/PngImagePlugin.py
Expand Up @@ -636,6 +636,7 @@ def _open(self):
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
Expand Down

0 comments on commit e9afb39

Please sign in to comment.