Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PNG seek and tell #4512

Merged
merged 3 commits into from Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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