LinuxCommandLibrary

pnmindex

Create image index file from multiple images

TLDR

Produce an image containing thumbnails of the specified images in a grid

$ pnmindex [path/to/input1.pnm path/to/input2.pnm ...] > [path/to/output.pnm]
copy

Specify the size of the (quadratic) thumbnails
$ pnmindex [[-s|-size]] [50] [path/to/input1.pnm path/to/input2.pnm ...] > [path/to/output.pnm]
copy

Specify the number of thumbnails per row
$ pnmindex [[-a|-across]] [10] [path/to/input1.pnm path/to/input2.pnm ...] > [path/to/output.pnm]
copy

Specify the maximum number of colors in the output
$ pnmindex [[-c|-colors]] [512] [path/to/input1.pnm path/to/input2.pnm ...] > [path/to/output.pnm]
copy

SYNOPSIS

pnmindex [-size N] [-across N] [-title "string"] [-black] [-white] [-dbuf] [-quantize | -noquant] [-colors N] [-verbose] [--] [netpbmfile ...]

PARAMETERS

-size N
    Set thumbnail size to N pixels square (default: 100)

-across N
    Number of thumbnails per row (default: 6)

-title "string"
    Page title (default: list of input filenames)

-black
    Black background for thumbnails

-white
    White background for thumbnails (default)

-dbuf
    Use double buffering for faster thumbnail generation

-quantize
    Quantize thumbnails to 256 colors (default)

-noquant
    Do not quantize thumbnails

-colors N
    Number of colors for quantization (default: 256)

-verbose
    Print progress information

--
    End of options; treat remaining args as filenames

DESCRIPTION

The pnmindex command generates an HTML document containing a table of thumbnail images from one or more input Netpbm files (PBM, PGM, PPM, or PAM). Each thumbnail is a scaled-down version of the input image, arranged in rows and columns for easy browsing.

It automatically scales images to a uniform size, applies optional quantization for color reduction, and supports custom backgrounds. The output is a self-contained HTML page viewable in web browsers, ideal for creating image galleries or indexes from directories of images.

Thumbnails link back to the original files if they are named appropriately (e.g., via relative paths). The tool is part of the Netpbm suite, efficient for batch processing large sets of images without needing external web servers.

CAVEATS

Input files must be valid Netpbm formats; output is HTML to stdout, redirect to file for saving. Thumbnails link to originals assuming same directory. Large inputs may consume significant memory.

INPUT HANDLING

If no files specified, reads multiple images from stdin until EOF. Filenames with spaces require quoting.

OUTPUT FEATURES

Generates clickable thumbnails with ALT text as filenames; includes CSS-like styling for table layout.

HISTORY

Part of the Netpbm graphics toolkit, originally developed by Jef Poskanzer in the early 1990s. Enhanced over years with quantization and buffering options in Netpbm versions post-10.x for better performance on large image sets.

SEE ALSO

Copied to clipboard