encodeGifAnimation function

List<int> encodeGifAnimation (
  1. Animation anim,
  2. {int samplingFactor: 30}

Encode an animation to the GIF format.

The samplingFactor specifies the sampling factor for NeuQuant image quantization. It is responsible for reducing the amount of unique colors in your images to 256. According to https://scientificgems.wordpress.com/stuff/neuquant-fast-high-quality-image-quantization/, a sampling factor of 10 gives you a reasonable trade-off between image quality and quantization speed. If you know that you have less than 256 colors in your frames anyway, you should supply a very large samplingFactor for maximum performance.

Here, 30 is used a default value for the samplingFactor as encoding animations is usually a process that takes longer than encoding a single image (see encodeGif).


List<int> encodeGifAnimation(Animation anim, {int samplingFactor = 30}) {
  return GifEncoder(samplingFactor: samplingFactor).encodeAnimation(anim);