I wondered why animated GIF files play endlessly when opened with spacebar in macOS Finder, but only play once when opened in a browser, so I looked into it.
There was a similar question on Stack Overflow with an answer saying “It’s defined in the gif file, so you need to edit to enable endless animation loops,” and I was oddly impressed thinking “Oh, of course that’s right.”
For editing gif files, I used Gifsicle, a Command-Line Animated GIFs tool.
brew install gifsicle
To set the loop count of original.gif to infinite, just run the gifsicle command with the -l, —loopcount option.
gifsicle --loopcount original.gif > output.gif
gifsicle -l original.gif > out.gif
You can also overwrite original.gif by adding the -b, —batch option.
gifsicle --batch --loopcount original.gif
gifsicle -bl original.gif
When you want to specify the loop count of original.gif, you can set it with the -l=N, —loopcount=N option.
For example, for 2 loops:
gifsicle --loopcount=2 original.gif > out.gif
gifsicle -l=2 original.gif > out.gif
can be used. In this case, the animated gif plays a total of 3 times.
That’s all from the field about wanting to make animated gifs loop playback.
That’s all from the Gemba.