#248 value for animationIteration is discarded when there is only 1 image

v1.0_(example)
closed-wont-fix
None
5
2013-11-21
2013-11-05
No

While saving a single image with the gif format, it is possible to set the number of loops with the animationIterations(). This works fine and after setting it, the same method retrieves the correct file (there's even tests for this on tests/attributes.cpp).

The problem is that when the file is actually written, this is discarded and a value of 1 is used instead.

I don't know of any other tool to inspect the content of GIF files so I guess it is also possible that the bug is on the reading of GIF files, i.e., if there is no other frames, it skips reading the actual value, and assumes a value of 1.

Discussion

  • Carnë Draug

    Carnë Draug - 2013-11-05

    I got my hands on a single image GIF with the animationIterations set to a specific value (5), and GM reads it correctly ("gm identify -verbose" shows an Iterations value of 5, and the animationIterations() also returns that value). This suggests that the bug is indeed on the writing.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2013-11-05

    What do you expect to happen (e.g. in the viewer/renderer/browser) if there is just one frame and the number of iterations is set to more than one?

     
  • Carnë Draug

    Carnë Draug - 2013-11-05

    I'm not sure what the GIF89 specification says but the same way that after looping the defined number of times it stays on the last frame, I'd expect that if there's only a single frame, it would stay there.

    I guess it's up to the viewer to try and draw the same image multiple times or to be "smart" enough to recognize that. But the bug is on the writing not on the reader (GM is able to read it correctly as can be checked with the sample image I attached on the first comment).

    The reason I have this problem it to implement writing animations in a loop (Matlab compatibe imwrite for Octave). Each call to imwrite either creates a file with a single frame or appends a frame to an existing file. Since setting animationIterations only makes sense on the first frame, setting that value when appending must be ignored. But then, GM discards the value when creating the file with a single frame (the moment where we need to actually set it).

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2013-11-21

    GIF is not a general purpose format. There is a common case (image gallery application) where saving/preserving the Netscape loop extension in single frame GIFs could cause harm. The reason for this is that it is common to read just the first frame of a sequence and use that as the image to display for the whole sequence. If the gallery software does not take extra precautions to specify '-loop 0' then any GIFs output by the gallery software would include the loop extension by default.

    GraphicsMagick is stable software. While the source change to allow saving the loop extension for single-frame GIF is trivial, I have no way to evaluate the impact on the hundreds (or thousands) of existing GIF readers so I am not willing to take the risk of this change.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2013-11-21
    • status: open --> closed-wont-fix
    • assigned_to: Bob Friesenhahn
     
  • Carnë Draug

    Carnë Draug - 2013-11-21

    I don't understand the reasoning. You mentioned that this can cause problems with readers but the issue is on the writer. Other GIF writers may specify the value of loop in single frame GIFs (and it will be doing so correctly). Are you assuming that the readers will only be reading GIFs written by GraphicsMagick?

    Also, what would happen on this image gallery applications when it is given a multi-frame GIF where the value of loop would make even more sense?

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2013-11-21

    On Thu, 21 Nov 2013, "Carnë Draug" wrote:

    I don't understand the reasoning. You mentioned that this can cause problems with readers but the issue is on the writer. Other GIF
    writers may specify the value of loop in single frame GIFs (and it will be doing so correctly). Are you assuming that the readers will
    only be reading GIFs written by GraphicsMagick?

    No, I am assuming that many different readers (beyond my control) will
    read GIFs written by GraphicsMagick. GraphicsMagick has been used to
    write billions of images.

    Also, what would happen on this image gallery applications when it is given a multi-frame GIF where the value of loop would make even
    more sense?

    It is normal for such gallery software to truncate image sequences and
    only show the first frame. If the loop extension is preserved, then
    this first frame will now include the loop extension.

    Bob

    --
    Bob Friesenhahn
    bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
    GraphicsMagick Maintainer, http://www.GraphicsMagick.org/

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks