You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In relation to @radarhere's comment here, I've discovered an edge case that does not fall into the behavior described.
What did you do?
But what you might notice in the above is that Pillow combines the duration of the frames. So if you add in duration to your code, then when opening the image back up again, you can detect the duration and use that to determine the original binary string.
I'm running into a similar issue as the reporter of #5928 and I believe I've found an edge case that doesn't follow the desired frame deduplication behavior.
First, let's presume we have a pre-existing animated gif file we open with Image.open. This gif already has durations specified and has duplicate frames, each with their own durations. Now, in the process of attempting to generate a thumbnail and perform some operations on the file, let's assume we save the file with save_all=True, but without specifying a duration because we want to leave the original file/frame durations unaltered.
Going by the state of main (currently 6a2545f6) and following the code, we're able to set the original frame's durations by falling back on the im_frame.info["duration"] as seen here:
As duration is none during the frame deduplication, it drops the duplicates but it never combines the durations into the prior frames. This ultimately results in an altered animation with notably different timings than the original.
At best guess, a fix might be to check if encoderinfo["duration"] instead of if duration, but I'm very unfamiliar with the codebase and don't have much confidence in that recommendation.
(Apologies, I cannot currently provide a sample of the image to help reproduce this bug. If I have time later, I'll try to mock one out with another tool to help reproduce the issue.)
What are your OS, Python and Pillow versions?
OS: Ubuntu 22.04
Python: 3.10.6
Pillow: 9.3.0
The text was updated successfully, but these errors were encountered:
In relation to @radarhere's comment here, I've discovered an edge case that does not fall into the behavior described.
What did you do?
I'm running into a similar issue as the reporter of #5928 and I believe I've found an edge case that doesn't follow the desired frame deduplication behavior.
First, let's presume we have a pre-existing animated gif file we open with
Image.open
. This gif already has durations specified and has duplicate frames, each with their own durations. Now, in the process of attempting to generate a thumbnail and perform some operations on the file, let's assume we save the file withsave_all=True
, but without specifying a duration because we want to leave the original file/frame durations unaltered.Going by the state of main (currently
6a2545f6
) and following the code, we're able to set the original frame's durations by falling back on theim_frame.info["duration"]
as seen here:Pillow/src/PIL/GifImagePlugin.py
Lines 592 to 593 in 6a2545f
...but when the deduplication check is performed, the same pattern of falling back on the frame's duration is not used:
Pillow/src/PIL/GifImagePlugin.py
Lines 621 to 622 in 6a2545f
As
duration
is none during the frame deduplication, it drops the duplicates but it never combines the durations into the prior frames. This ultimately results in an altered animation with notably different timings than the original.At best guess, a fix might be to check
if encoderinfo["duration"]
instead ofif duration
, but I'm very unfamiliar with the codebase and don't have much confidence in that recommendation.(Apologies, I cannot currently provide a sample of the image to help reproduce this bug. If I have time later, I'll try to mock one out with another tool to help reproduce the issue.)
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: