diff --git a/Tests/images/apng/different_durations.png b/Tests/images/apng/different_durations.png new file mode 100644 index 00000000000..984254b8e56 Binary files /dev/null and b/Tests/images/apng/different_durations.png differ diff --git a/Tests/test_file_apng.py b/Tests/test_file_apng.py index 60d951636e8..e2c4569cee5 100644 --- a/Tests/test_file_apng.py +++ b/Tests/test_file_apng.py @@ -689,3 +689,12 @@ 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_repeated_seeks_give_correct_info() -> None: + with Image.open("Tests/images/apng/different_durations.png") as im: + for i in range(3): + im.seek(0) + assert im.info["duration"] == 4000 + im.seek(1) + assert im.info["duration"] == 1000 diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index e4ed9388011..823f1249285 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -378,7 +378,7 @@ def save_rewind(self): } def rewind(self): - self.im_info = self.rewind_state["info"] + self.im_info = self.rewind_state["info"].copy() self.im_tile = self.rewind_state["tile"] self._seq_num = self.rewind_state["seq_num"]