4

I have been following this online guide to convert a small video clip into image frames, then combine them together into a single animated GIF.

The problem I'm having is that each GIF tends to be fairly large, both in filesize and dimensions(640x480 or something similar). I have seen gifs at 640x480 that come out around ~2-3MB and that is fairly reasonable.

Most of my GIFs turn out to be way larger than 10MB, often 25-30MB total. Even sizing down smaller to 320x240 does not help very much and it's frustrating because these GIFs can't be quickly uploaded to image hosts like Imgur.

Is there a method I can use to force an output size for these GIFs? Like a command through Gifsicle that will require the final output to be ~2MB or something like this? I've gone through the online docs and I cannot find any good information about this topic. Would really appreciate any advice from people who use the CLI for this kind of image manipulation. Here's a copy of the gifsicle command from that guide:

gifsicle -O3 --colors 256 Almost.gif > Done.gif
Jake
  • 141

1 Answers1

0

Even without an explicit request for the final size it is possible to use some commands to contain the final size. Everything that follows can be used on the command used to create the image or you can work on the already created gif.

Remember that imagemagick can produce different results with a different sequence of parameters on the command line.

convert input.gif -coalesce -scale 640x480 -fuzz 10% +dither -remap input.gif[0] -layers Optimize output.gif
  • -coalesce merge a sequence of images

  • -scale scale the image (better than -resize)

  • -fuzz help to reduce the size you can try with higher percentage values.
    Read here some word more about it.

  • +dither eventually with -colors XX to reduce the number in the color map, of course better in the 1st

  • -remap filename transform image colors to match this set of colors in this case the 1st frame.

  • -layers method optimize, merge, or compare image layers

A more complex command line can require to reduce the number o color of the first frame

convert input.gif -coalesce -scale 700x525 -fuzz 2% +dither -remap \( input.gif[0] +dither -colors XX \) -layers Optimize output.gif

You can read more, e.g., on this discussion [1].

Hastur
  • 19,483
  • 9
  • 55
  • 99