Skip to content

Commit e9afb39

Browse files
authored
Merge pull request #4512 from hugovk/fix-png-seek
Fix PNG seek
2 parents 0a77f73 + 2e9030d commit e9afb39

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

Tests/test_file_png.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,14 @@ def test_exif_argument(self, tmp_path):
629629
with Image.open(test_file) as reloaded:
630630
assert reloaded.info["exif"] == b"Exif\x00\x00exifstring"
631631

632+
def test_tell(self, tmp_path):
633+
with Image.open(TEST_PNG_FILE) as im:
634+
assert im.tell() == 0
635+
636+
def test_seek(self, tmp_path):
637+
with Image.open(TEST_PNG_FILE) as im:
638+
im.seek(0)
639+
632640

633641
@pytest.mark.skipif(is_win32(), reason="Requires Unix or macOS")
634642
@skip_unless_feature("zlib")

src/PIL/PngImagePlugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ def _open(self):
636636
if self.fp.read(8) != _MAGIC:
637637
raise SyntaxError("not a PNG file")
638638
self.__fp = self.fp
639+
self.__frame = 0
639640

640641
#
641642
# Parse headers up to the first IDAT or fDAT chunk

0 commit comments

Comments
 (0)