GIF libraries for Go
- image/gif in the standard library reads and writes GIF, including animation:
gif.DecodeAllreturns every frame as an*image.Palettedwith delays, disposal methods and the loop count, andgif.EncodeAllwrites them back. Frames are raw (not composited). Encoding an RGB image maps it to the fixed Plan 9 palette with Floyd-Steinberg dithering unless you pass your own quantizer.
For resizing and other processing of the frames, imaging and golang.org/x/image/draw work on the decoded images. For higher-quality palettes, use a quantizer package such as ericpauley/go-quantize (BSD-3-Clause, median cut), which plugs into gif.Options.Quantizer.
- image/gif Go's standard image/gif package reads and writes GIF and animated GIF. How to decode all frames with delays, composite them, create a looping animation.