LinuxCommandLibrary

pnmcat

Concatenate multiple PNM images into one

SYNOPSIS

pnmcat [-left | -right | -top | -bottom] [-spacing=N] [-border=N] [-background=color] [pnmfiles...]

PARAMETERS

-left
    Concatenates images horizontally, aligning them to the left edge of the composite image.

-right
    Concatenates images horizontally, aligning them to the right edge of the composite image.

-top
    Concatenates images vertically, aligning them to the top edge of the composite image (this is the default behavior if no direction is specified).

-bottom
    Concatenates images vertically, aligning them to the bottom edge of the composite image.

-force
    Forces concatenation even if image dimensions do not perfectly match, potentially truncating or clipping larger images.

-spacing=N
    Specifies N pixels of transparent space to be added between concatenated images.

-border=N
    Adds a border of N pixels around each individual image before concatenation.

-background=color
    Sets the background color for spaces, borders, and margins. The color can be a name (e.g., 'red') or a hexadecimal RGB value (e.g., '#FF0000').

-margin=N
    Adds a margin of N pixels around the entire final output image.

-jigsaw
    Enables a specialized 'jigsaw' mode to arrange images into a mosaic, attempting to fill a specified area. This option requires other -jigsaw_... parameters to control its behavior.

-jigsaw_width_max=N
    Sets the maximum width for individual cells in 'jigsaw' mode.

-jigsaw_height_max=N
    Sets the maximum height for individual cells in 'jigsaw' mode.

-jigsaw_width_min=N
    Sets the minimum width for individual cells in 'jigsaw' mode.

-jigsaw_height_min=N
    Sets the minimum height for individual cells in 'jigsaw' mode.

-jigsaw_average_pixels=N
    Sets the target average number of pixels for each cell in 'jigsaw' mode.

-jigsaw_random_order
    Arranges the images in a random order when using 'jigsaw' mode.

-jigsaw_vertical_first
    Prioritizes vertical arrangement before horizontal when placing images in 'jigsaw' mode.

-jigsaw_force_width=N
    Forces the total output width of the 'jigsaw' mosaic to be N pixels.

-jigsaw_force_height=N
    Forces the total output height of the 'jigsaw' mosaic to be N pixels.

DESCRIPTION

pnmcat is a utility from the Netpbm suite used to concatenate multiple Portable Anymap (PNM) image files into a single output image. PNM refers to the PBM (Portable BitMap), PGM (Portable GrayMap), and PPM (Portable PixMap) formats. By default, pnmcat concatenates images vertically, stacking them one above the other. Users can specify horizontal concatenation (side-by-side) or control alignment. It offers options for adding spacing, borders, and margins, and even a specialized 'jigsaw' mode for creating mosaics. This command is particularly useful for creating simple image montages or combining a series of images into a single strip.

CAVEATS

Input images are generally expected to be of compatible Netpbm types (PBM, PGM, PPM) and have compatible maxval settings, though pnmcat attempts some conversions. Using the -force option can result in images being truncated or clipped if their dimensions do not align with the concatenation direction. The specialized 'jigsaw' mode requires careful tuning of its associated parameters for optimal results.

INPUT AND OUTPUT

pnmcat reads PNM image data from files specified as arguments on the command line. If no filenames are provided, it reads image data from standard input. The concatenated PNM image is always written to standard output. Users commonly redirect this output to a file using shell redirection (e.g., pnmcat img1.pnm img2.pnm > output.pnm).

DEFAULT CONCATENATION

When no specific direction option (like -left or -right) is used, pnmcat defaults to concatenating images vertically. This means images are stacked one above the other, starting from the top and progressing downwards.

HISTORY

pnmcat is an integral part of the Netpbm project, a widely used and venerable toolkit for manipulating graphic images. The origins of Netpbm lie in a collection of separate utilities for PBM, PGM, and PPM formats (Pbmplus, Pgmplus, Ppmplus) created by Jef Poskanzer. These tools were designed following the Unix philosophy of small, specialized utilities that can be chained together. Over time, these distinct projects were merged and expanded into the unified Netpbm package, with pnmcat serving as a foundational component for basic image assembly.

SEE ALSO

netpbm(1), pnm(5), pnmstitch(1), pnmpaste(1), pnmcut(1)

Copied to clipboard