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 APNG info after seeking backwards more than twice #7701

Merged
merged 6 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Tests/images/apng/issue_7700.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions Tests/test_file_apng.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,3 +689,13 @@ def test_different_modes_in_later_frames(mode, default_image, duplicate, tmp_pat
)
with Image.open(test_file) as reloaded:
assert reloaded.mode == mode


def test_apng_issue_7700():
esoma marked this conversation as resolved.
Show resolved Hide resolved
# https://github.com/python-pillow/Pillow/issues/7700
with Image.open("Tests/images/apng/issue_7700.png") as im:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you give the test and image more descriptive names than issue_7700?

for i in range(5):
im.seek(0)
assert im.info["duration"] == 4000.0
im.seek(1)
assert im.info["duration"] == 1000.0
esoma marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion src/PIL/PngImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
}

def rewind(self):
self.im_info = self.rewind_state["info"]
self.im_info = self.rewind_state["info"].copy()

Check warning on line 381 in src/PIL/PngImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/PngImagePlugin.py#L381

Added line #L381 was not covered by tests
self.im_tile = self.rewind_state["tile"]
self._seq_num = self.rewind_state["seq_num"]

Expand Down
Loading