Creating GIFs in the Command Line
14 Jan 2017Table of Contents
Creating GIFs in the Command Line is a quick and easy way to create GIFs from images or videos. You can use any image or video editing software to create your GIFs, but the command line is a great way to make simple GIFs with just a few commands.
Creating GIFs Using ImageMagick
The tool I mostly use is convert
from ImageMagick. The -fuzz
option seems to have the largest impact on the final size, which has the effect that Colors within this distance are considered equal. The -delay
option specifies the the delay of each frame in ticks-per-second. The -loop
option specifies the number of loops (0 for infinite loop). The -layers
option performs different image operation methods for image sequences, where OptimizePlus
is improving the overall optimization. The convert
options can be found in the Command Line Options.
convert \
-fuzz 6% \
-delay 4 \
-loop 0 \
-layers OptimizePlus \
frames/*.png tmp.gif
Optimize GIFs Using Gifsicle
The file size can be further shrinked even more with Gifsicle by decreasing the colors and optimize the output. The option -O3
is the maximum level. The different available commands can be found on the Gifsicle Man Page.
gifsicle -O3 --colors 100 \
tmp.gif > output.gif
Gifsicle can convert image sequences into GIFs by itself, but I found out that both tools perform better together. Also after installing ImageMagick on windows, the commands work there too.