## Introduction to GIFLIB

### Eric Steven Raymond

Thyrsus Enterprises

`<esr@thyrsus.com>`

Copyright © 2012 Eric S. Raymond

GIFLIB is a package of portable tools and library routines for working with GIF images.

The Graphics Interchange Format(c) specification is the copyrighted property of CompuServe Incorporated. GIF(sm) is a service mark property of CompuServe Incorporated.

This package has been released under an X Consortium-like open-source license. Use and copy as you see fit. If you make useful changes, add new tools, or find and fix bugs, please send your mods to the maintainers for general distribution.

The util directory includes programs to clip, rotate, scale, and position GIF images. These are no replacement for an interactive graphics editor, but they can be very useful for scripted image generation or transformation.

The library includes program-callable entry points for reading and writing GIF files, an 8x8 utility font for embedding text in GIFs, and an error handler. GIF manipulation can be done at a relatively low level by sequential I/O (which automatically does/undoes image compression) or at a higher level by slurping an entire GIF into allocated core.

This library speaks both GIF87a and GIF89. The differences between GIF87 and GIF89 are minor: in the latter, the interpretation of some extension block types is defined. The library never needs to actually interpret these, but giftext notices them and there are functions in the API to read and modify them.

## Utilities

Here is a summary of the utilities in this package. If you're looking at this page through a web browser, each utility name should be a hotlink to HTML documentation.

Most utilities have a -v (verbose) option that will cause them to print the current input scan line number (counting up) whenever they read image input, and will print output image line number (counting down) when they dump output. Utilities that only read or write always print in increasing order.

### Conversion Utilities

gif2rgb

  convert images saved as GIF to 24-bit RGB image(s) or vice-versa

### Test Pattern Generators

gifbg

  generate a single-color test pattern GIF

gifcolor

  generate color test patterns

gifwedge

  create a test GIF image resembling a color monitor test pattern

### Image Manipulation Components

gifclrmp

  modify GIF image colormaps

giffix

  clumsily attempts to fix truncated GIF images

### Report Generators

giftext

  print (text only) general information about a GIF

gifhisto

  generate color-frequency histogram from a GIF

### GIF Composition Tools

gifbuild

  converter/deconverter to/from an editable text format

gifecho

  generate GIF images out of regular text in 8x8 font

gifinto

  end-of-pipe fitting for GIF-processing pipelines

giftool

  GIF transformation tool

## Library Functions

The library contains two groups of C functions. One group does sequential I/O on the stream-oriented GIF format. The other supports grabbing an entire GIF into allocated core, operating on it in core, and then writing the modified in-core GIF out to disk.

Unless you are on extremely memory-limited machine, you probably want to use the second group.

Detailed documentation on the library entry points is in gif_lib.html.

## The GIF Standard

The doc subdirectory includes an HTML presentation of the GIF standard; an explanation of Lempel-Ziv compression, and the original flat-ASCII description of GIF89 format . For historical completeness, we also include a copy of the GIF87 standard.

You can also read a detailed narrative description of how GIFs are laid out. It clarifies some points on which the standard is obscure.

## Package Status

GIFLIB's current maintainer is Eric S. Raymond. You can find his home page at http://catb.org/~esr/.

GIFLIB is not under active development, but bug fixes are being accepted.