Magick vs. gifsicle - why such a difference when combining gif's?

1.4k views Asked by At

I combine 3 gifs of about 3M each into a bigger gif.

So far I have used magick and convert to do the job but they ended up consuming more than 6G of RAM and to be killed (...).

convert pic1.gif pic2.gif pic3.gif final.gif

Googling around I found gifsicle, which ended up combining my three gif in a very short time and consuming very little RAM...

gifsicle pic1.gif pic2.gif pic3.gif > final.gif

As a front end user I have only a limited comprehension of these tools, but how can the performances be so different between convert (magick) and gifsicle?

1

There are 1 answers

0
fmw42 On BEST ANSWER

Gifsicle does special optimization just for gif. ImageMagick is a general purpose image processor and does not optimize gifs as well. Its quantization code is accurate but slow. Each of your images needs to be quantized to 256 colors or less. Since your images are Gifs, they are already quantized to 256 colors or less. But each might use different sets of colors. In ImageMagick, it would be best to find one common set of colors and use -remap color_map_image to convert all the input images to the same set of colors. This will reduce file size. You can just append the 3 input gifs and get the unique colors for the color map image. You can also add -layers optimize to potentially further reduce the file size.

convert pic1.gif pic2.gif pic3.gif \
+append +dither -colors 256 -unique-colors colormap.gif

convert \
\( pic1.gif +dither -remap colormap.gif \)
\( pic2.gif +dither -remap colormap.gif \)
\( pic3.gif +dither -remap colormap.gif \)
-layers optimize \
final.gif


However, gifsicle may still be better as it is a specialized tool just for gif images.

See also https://imagemagick.org/Usage/formats/#gif_non-im