LinuxCommandLibrary

ppmquantall

Reduce colors in multiple PPM images

TLDR

View documentation for the current command

$ tldr pnmquantall
copy

SYNOPSIS

ppmquantall [options] [ppmfile...]

PARAMETERS

-maxcolors=N
    Specifies the maximum number of colors to use in the output common colormap. The default is usually 256. Setting a lower number reduces palette size but may impact image quality.

-floyd
    Enables Floyd-Steinberg dithering, which is the default behavior for spreading quantization errors to reduce banding.

-nofloyd
    Disables Floyd-Steinberg dithering. This can result in sharper color boundaries and potentially more noticeable color banding.

-gamma=gamma_value
    Adjusts the gamma correction applied during color quantization. This influences how colors are perceived and mapped to the new palette.

-nicer
    Instructs ppmquantall to spend more time finding a 'nicer' or more perceptually optimal colormap. This may increase processing time but can result in better visual quality.

-noverbose
    Suppresses verbose output, showing only essential information or errors during processing.

-verbose
    Enables verbose output, providing more detailed information about the processing steps and progress.

DESCRIPTION

ppmquantall reads a set of PPM (Portable Pixmap), PGM (Portable Graymap), or PBM (Portable Bitmap) image files and outputs a new set of corresponding image files.

The key function is to quantize all input images to a single, common colormap. This colormap is optimally derived from the combined color information of all input images. This command is particularly valuable when creating animations (e.g., GIFs) or collections of images that need to share a limited palette, which helps in reducing file size and maintaining visual consistency across multiple frames or images.

Internally, ppmquantall first analyzes all input images to build a master colormap and then applies ppmquant to each individual image, mapping its colors to this newly created shared palette. Output files are typically named by appending a suffix (e.g., .out.ppm) to the input filenames.

CAVEATS

Processing can be memory-intensive and time-consuming for a large number of high-resolution input images. This is due to the need to load and analyze all images to construct the optimal master colormap.

Output files are created in the current directory with names derived from the input files (e.g., appending .out.ppm), which might overwrite existing files if not handled carefully.

INPUT AND OUTPUT

ppmquantall accepts PPM, PGM, or PBM files as input. The output files will maintain the same format as the input (e.g., PPM for PPM input) and are named by adding a suffix like .out.ppm to the original filename. While it can process input from standard input if no files are specified, its primary utility and design are for handling multiple distinct image files provided as arguments.

TYPICAL USE CASE

A very common application for ppmquantall is preparing a series of images (e.g., frames of an animation) before converting them to a format such as GIF. By ensuring all frames share the same optimal color palette, the resulting GIF file can be significantly smaller in size and maintain consistent visual quality without noticeable palette shifts between frames, which is vital for smooth animations.

HISTORY

ppmquantall is a utility within the comprehensive Netpbm open-source graphics toolkit. Netpbm itself has a long history, evolving from the original PBMPLUS package (first released in 1988) and becoming Netpbm in 1991. The command was developed to address the specific need for consistent color palettes across multiple images, which is crucial for efficient animation and image sequence creation, especially for formats with limited palettes like GIF.

SEE ALSO

Copied to clipboard