LinuxCommandLibrary

giftoppm

Convert GIF files to PPM

SYNOPSIS

giftoppm [-interlace] [-map] [-verbose] [-alphaout=alpha.ppm] [-background=color] [-comment] [-index] [giffile]

PARAMETERS

-interlace
    Produce interlaced PPM output (default follows GIF's native form).

-map
    Output a PPM file of the GIF colormap (appends .map to input filename).

-verbose
    Print processing information and errors to stderr.

-alphaout=file.ppm
    Save transparency mask as PBM or PAM to specified file.

-background=color
    Fill transparent pixels with given color (format as in ppm(5)). Default black.

-comment
    Embed GIF comments as PPM comments in output.

-index
    Output PGM file(s) with colormap index values instead of colors.

DESCRIPTION

The giftoppm command is a graphics conversion utility from the Netpbm suite that reads one or more GIF images from a file (or standard input) and outputs them as portable pixmap (PPM) images to standard output. It supports both GIF87a and GIF89a formats, including animated GIFs by producing a concatenated stream of PPM images—one per GIF frame.

GIF files often feature a limited 256-color palette, transparency, and comments, which giftoppm handles via options like -alphaout for extracting transparency masks and -comment for embedding GIF comments into PPM headers. The output PPM is a simple, widely supported binary format suitable for further processing with other Netpbm tools. Interlacing, colormap dumps, and index maps are available for advanced use cases.

This tool is lossless when converting back with ppmtogif, preserving GIF properties where possible. It's ideal for batch conversion, scripting image pipelines, or preparing GIFs for formats lacking native GIF support. Note that for single-frame GIFs, output is a single PPM; multi-frame yields multiple concatenated PPMs, which may require tools like pnmcut or pnmsplit to separate.

CAVEATS

Outputs concatenated PPMs for multi-frame GIFs; use pnmsplit(1) to separate. LZW decompression may fail on malformed GIFs. No animation timing info preserved.

INPUT HANDLING

Reads from giffile or stdin if omitted. Processes all images sequentially.

COLOR SPECIFICATION

color format: name (e.g. red), rgb (r/g/b), or integer (0-65535 per channel). See ppm(5).

HISTORY

Developed by Jef Poskanzer in 1990 as part of PBMPLUS (precursor to Netpbm). Enhanced in Netpbm releases for GIF89a transparency, alpha output (2000s), and long options. Widely used despite historical Unisys LZW patent concerns (expired 2003).

SEE ALSO

ppmtogif(1), giftopnm(1), pnmsplit(1), ppm(5), pnm(5)

Copied to clipboard