LinuxCommandLibrary

pnmmontage

Create image montages from multiple images

TLDR

Produce a packing of the specified images

$ pnmmontage [path/to/image1.pnm path/to/image2.pnm ...] > [path/to/output.pnm]
copy

Specify the quality of the packing (Note: Larger values produce smaller packings but take longer to compute.)
$ pnmmontage -[0..9] [path/to/image1.pnm path/to/image2.pnm ...] > [path/to/output.pnm]
copy

Produce a packing that is not larger than p percent of the optimal packing
$ pnmmontage [[-qua|-quality]] [p] [path/to/image1.pnm path/to/image2.pnm ...] > [path/to/output.pnm]
copy

Write the positions of the input files within the packed image to a machine-readable file
$ pnmmontage [[-d|-data]] [path/to/datafile] [path/to/image1.pnm path/to/image2.pnm ...] > [path/to/output.pnm]
copy

SYNOPSIS

pnmmontage [options] [pnmfile...]
Common options include:
pnmmontage [-background color] [-borderwidth width] [-bordercolor color] [-grid rowsxcols] [-equal] [-novertical] [-verbose] [pnmfile...]

PARAMETERS

-background color
    Specifies the background color for empty cells in the grid or for the overall image if parts are not filled. Default is white. Colors can be specified using HTML color names, hexadecimal RGB codes (e.g., `#RRGGBB`), or the `rgb:RR/GG/BB` format.

-borderwidth width
    Sets the width (in pixels) of the border to be drawn around each individual image within the montage. The default is 0 (no border).

-bordercolor color
    Defines the color of the borders drawn around each image. The default border color is black. Color specification follows the same rules as -background.

-grid rowsxcols
    Explicitly sets the dimensions of the grid as rows by columns (e.g., `3x4` for 3 rows and 4 columns). If omitted, pnmmontage attempts to create a squarish grid.

-equal
    Forces all input images to be scaled to the same size within their grid cells. Without this option, each image is scaled independently to fit its allocated cell.

-novertical
    Prevents images from being scaled vertically. Images are scaled horizontally to fit their cell width, and their cell height is adjusted to maintain the original aspect ratio. This is useful for preserving image proportions.

-verbose
    Enables verbose output, causing pnmmontage to print informational messages about its progress and actions to standard error.

pnmfile...
    One or more input Netpbm image files (PBM, PGM, or PPM) to be included in the montage. If no files are specified, pnmmontage reads a concatenated stream of Netpbm images from standard input.

DESCRIPTION

pnmmontage is a command-line utility from the Netpbm suite designed for creating image montages or contact sheets. It takes multiple Netpbm format images (PBM, PGM, or PPM) as input and arranges them into a single, larger image, typically in a grid layout. This tool is invaluable for tasks such as creating visual overviews of image collections, comparing multiple images side-by-side, or simply combining related graphics into a single displayable unit. pnmmontage automatically scales input images to fit within their respective grid cells, ensuring all images are visible. Users can customize the grid dimensions, add borders around individual images, specify border and background colors, and control scaling behavior to suit specific needs. The output is always a new Netpbm image, usually in PPM format if any input images are color, or PGM/PBM otherwise.

CAVEATS

pnmmontage is designed exclusively for Netpbm image formats (PBM, PGM, PPM). It does not support other image formats directly; external tools like anytopnm would be needed for conversion. The output is always a single Netpbm image written to standard output, which requires redirection to a file for saving. While it handles scaling, precise control over individual image positioning or complex layering is not available. For very large numbers of high-resolution images, memory consumption can be significant.

OUTPUT FORMAT

The output of pnmmontage is always a single Netpbm image written to standard output. If any of the input images are color (PPM), the output will be a PPM image. If all input images are grayscale (PGM) or black & white (PBM), the output will be PGM or PBM respectively, preserving the highest common denominator format. This output typically needs to be redirected to a file, for example: `pnmmontage image1.pnm image2.pnm > montage.pnm`.

COLOR SPECIFICATION

Colors for options like -background and -bordercolor can be specified in several ways:
1. Named colors (e.g., "white", "black", "red").
2. Hexadecimal RGB codes (e.g., `"#FFFFFF"` for white).
3. The `rgb:RR/GG/BB` format (e.g., `rgb:FF/FF/FF`).

HISTORY

pnmmontage is an integral part of the Netpbm project, a suite of graphics manipulation programs that evolved from the earlier PBMplus package. The Netpbm philosophy emphasizes small, simple, and specialized tools that can be chained together using pipes to perform complex image processing tasks. pnmmontage adheres to this design principle by focusing solely on arranging Netpbm images into a grid, leveraging the strengths of the Netpbm ecosystem for input and output. Its development has mirrored the Netpbm project's ongoing efforts to maintain compatibility and efficiency across various Unix-like systems.

SEE ALSO

netpbm(1), pnm(5), pnmcat(1), pnmscale(1), pamstack(1), convert(1)

Copied to clipboard