That is very strange! Not the fact that it is a large frame. That is understandable as it is a 'background' dispose frame. Normal identify does not show the disposal setting...
Use this to show animation relevant attributes...
Code: Select all
identify -format '%s: %wx%h%O %Tcs %D\n' optimized.gif
I would have expected something like a 31x29 image for the 3rd (index 2) frame.
Hmmm removing all optimizations from the animation (using
-coalesce) shows that some pixels between index 2 and 3 were made transparent. That is because
-coalesce set a disposal of background for frame index 2. Cooalesce always uses a none disposal, unless some pixel became transparent in which can it sets background dispose, so the coalesced animation will still continue to work correctly.
Looking at the animation on a checkered background shows a lot of white edge 'anti-aliasing pixels' . That seems to indicate that the animation was originally created on a pure white background. It is a change in these white pixels (a few vanished in frame index 3) that caused the need to use a background dispose at that point. This was confirmed using
-layers compare_clear.
Of course later frames also needs to convert some pixels back to transparency later, but than those frame are optimizing correctly. Or at least does not seem to be over doing it.
It however does not explain why the image size of index 2 is overly large! At most it should only be large enough to contain transparent pixels that changed from index 1 to 2 and the small number of pixels that were cleared from index 2 to 3. Or at maximum all the pixels that was added in this and all previous frames. It definatally should not be the whole virtual canvas!
As such this does appear to be a bug, and I will investigate further using this animation.
Thank you for bringing this to my attention. Good spotting.
PS: Adding a
-fuzz 10% should make the image optimize even better but more frames appear to suddenly become 'full virtual canvas'. It is also definitely coming from the optimize_frame sub-component of optimize.
Now to find out its cause! Code diving is the next step.