All formats

GIF libraries

Open-source libraries that decode and encode GIF files. Every image library reads the first frame; the differences are in animation: whether the library returns all frames, whether it composites them on the canvas (applying disposal methods) or gives you the raw sub-rectangles, and whether it can write animated GIFs with delays and a loop count. Writing a good GIF also needs color quantization from RGB to a 256-color palette, which some libraries do well and some leave to you.

Language Library Read Write Notes
C/C++ GIFLIB yes yes animation: read and write; reference C library, raw frames, no quantizer
C/C++ stb_image yes no animation: read (composited); single header, public domain
C# ImageSharp yes yes animation: read and write; pure managed code; Six Labors Split License
C# Magick.NET yes yes animation: read and write; ImageMagick for .NET, coalesce and optimize
Java ImageIO yes yes animation: read and write (raw frames); built into the JDK, metadata tree for delays
Go image/gif yes yes animation: read and write (raw frames); standard library
Python Pillow yes yes animation: read and write (composited); the standard Python imaging library
Ruby ruby-vips yes yes animation: read and write; libvips with cgif and libimagequant
Ruby MiniMagick yes yes animation: read and write; wraps ImageMagick command line
Rust gif yes yes animation: read and write (raw frames); pure Rust, streaming, used by image
Rust image yes yes animation: read and write (composited); high-level, many formats
PHP GD yes yes no animation (first frame only); bundled with PHP
PHP Imagick yes yes animation: read and write; ImageMagick extension
PHP Intervention Image yes yes animation: read and write; animated GIF with GD or Imagick drivers

By language#