I’ve had far more trouble getting the generation of gif animations to work satisfactorily than I thought was necessary so I decided to share my conclusions and hopefully you’ll waste less time than I did. I’ve provided ┬ásource code for a command line tool that you can run to generate gif animations.

The source is provided as a gist.

My major problem was that there is little or no documentation about which properties are related to the gif file and which to individual frames. Adding a UnclampedDelayTime property to the gif properties for a frame is pointless. It is ignored. It is a property that you can read from an individual frame in an already generated gif animation but is not a property that you can add.

The other issue is that CoreGraphics (Core-Graphics, Quartz) limits the values you can specify for the delay time. For any frame delay time specified to be more than 0.1 second it needs to be a multiple of 0.5 seconds (so 0.5, 1.0, 1.5, 2.0 … etc.) and if it isn’t the frame delay time is set to 0.1 second. The frame delay time cannot be set to less than 0.1 seconds. None of this information is provided in the ImageIO documentation. To work this out I needed to write this tiny command line tool as I was confused about the results I was getting.

I don’t add the functionality for adding customised colour tables to the gif animation. But to see details how to do that you can see this stack overflow discussion (custom gif colour table).