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

Seeking APNG to frame 0 multiple times breaks the info attribute #7700

Closed
esoma opened this issue Jan 7, 2024 · 0 comments · Fixed by #7701
Closed

Seeking APNG to frame 0 multiple times breaks the info attribute #7700

esoma opened this issue Jan 7, 2024 · 0 comments · Fixed by #7701
Labels
Bug Any unexpected behavior, until confirmed feature.

Comments

@esoma
Copy link
Contributor

esoma commented Jan 7, 2024

What did you do?

  • Load an APNG with 3 frames with different durations (let us imagine the first frame has a duration of 1ms, the second frame has a duration of 2ms and the third frame has a duration of 3m)
  • iterate through the image - looking at the duration supplied by the info dict, output will appropriately be (1ms, 2ms, 3ms)
  • do the same thing, output will appropriately be (1ms, 2ms, 3ms)
  • do the same thing, output will incorrectly be (3ms, 2ms, 3ms)

What did you expect to happen?

The duration value per frame should be accurate no matter how many times the image is seeked

What actually happened?

After the 2nd loop through the first frame will always have the info attributes of the last frame iterated.

What are your OS, Python and Pillow versions?

  • OS: Linux
  • Python: 3.12
  • Pillow: 10.2.0

The problem is, afaik, specific to APNG. When seeking the Image to the first frame the PngStream goes through a "rewind", in which it assigns the rewind_state (generated on the first read of the first frame) to the current state of the object. However, the rewind state im_info is simply assigned to the current state, not copied. This means the rewind state info object is later modified inadvertently because current and rewind state share the same object.

self.im_info = self.rewind_state["info"]

This should be:

self.im_info = self.rewind_state["info"].copy()
@radarhere radarhere added the Bug Any unexpected behavior, until confirmed feature. label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants