LinuxCommandLibrary

pnmcat

Concatenate multiple PNM images into one

SYNOPSIS

pnmcat [-left|-right|-lr|-rl|-top|-bottom|-tb|-bt] [-white|-black|-center|-lr|-tb] [-jspace=N] [-vspace=N] [pnmfile

PARAMETERS

-left or -lr
    Horizontal concatenation left-to-right (first image leftmost; default direction).

-right or -rl
    Horizontal concatenation right-to-left (first image rightmost).

-top or -tb
    Vertical concatenation top-to-bottom (first image topmost).

-bottom or -bt
    Vertical concatenation bottom-to-top (first image bottommost).

-white
    Align images by matching whitespace borders (centers on white padding).

-black
    Align images by matching black borders.

-center
    Center-align images perpendicular to concatenation direction.

-lr or -tb
    Alignment shorthands: left/right or top/bottom justify.

-jspace=N
    Insert N pixels blank space horizontally between images (default 0).

-vspace=N
    Insert N pixels blank space vertically between images (default 0).

DESCRIPTION

pnmcat is a utility from the Netpbm graphics suite designed to combine multiple PNM (Portable aNyMap) images—including PBM (monochrome bitmaps), PGM (grayscale), and PPM (RGB pixmaps)—into a single image by placing them side-by-side horizontally or stacked top-to-bottom vertically.

By default, it performs left-to-right horizontal concatenation. Directional options like -left, -right, -top, or -bottom control the order and orientation. Alignment options such as -center, -white, or -black handle positioning when images differ in height (for horizontal) or width (for vertical) by centering, or matching assumed whitespace/black borders.

Custom spacing is available via -jspace=N (horizontal padding between images) and -vspace=N (vertical padding), with N in pixels (default 0). Inputs can be files or standard input; if no files specified, reads from stdin until EOF. Output is a single PNM image to stdout, automatically promoting formats to a common type (e.g., all to PPM if any input is PPM).

Ideal for scripting image strips, contact sheets, or simple montages. Limitations include no resizing or complex layouts; pair with tools like pnmscale for scaling.

CAVEATS

Does not resize or crop images; uses original sizes with alignment. Single input passes through unchanged. Mixed formats promote to highest type (e.g., PBM+PPM → PPM). No stdin EOF detection on some pipes; specify files explicitly.

EXAMPLES

pnmcat img1.ppm img2.ppm > horiz.ppm
pnmcat -tb -center *.pgm > vert.pgm
pnmcat -right -jspace=10 -vspace=5 shots*.pnm | pnmtopng > montage.png

NOTES

Output maxval matches maximum input. Use -quiet not available; verbose via Netpbm env vars. Pipe to viewers like display or converters.

HISTORY

Developed by Jef Poskanzer as part of Netpbm suite (started 1988); pnmcat added early 1990s for basic image concatenation. Maintained by Netpbm community with periodic updates for portability.

SEE ALSO

pnmmontage(1), pnmscale(1), pnmcrop(1), pbm(5), pgm(5), ppm(5)

Copied to clipboard