LinuxCommandLibrary

pnminterp

Interpolate between two PNM image files

TLDR

View documentation for the current command

$ tldr pamstretch
copy

SYNOPSIS

pnminterp [-linear|-cubic] nframes frompnm topnm

PARAMETERS

-cubic
    Use cubic interpolation for smoother transitions (default: linear)

nframes
    Number of output frames to generate (integer ≥ 2)

frompnm
    PNM input file for the starting image (use '-' for stdin)

topnm
    PNM input file for the ending image (use '-' for stdin)

DESCRIPTION

The pnminterp command generates a sequence of nframes intermediate PNM images that smoothly transition from the first input image (frompnm) to the second (topnm). Both input images must have identical dimensions (width and height) and the same maxval. The output is a single stream of concatenated PNM images written to standard output, suitable for piping to other tools or files.

By default, pnminterp uses linear interpolation, which computes each output pixel as a weighted average between corresponding pixels in the input images. The -cubic option enables cubic interpolation for smoother, more natural-looking transitions, especially useful for animations or morphing effects. The first output frame is an exact copy of frompnm, and the last frame matches topnm.

For PBM (monochrome) images, pixels are treated as grayscale values (0 or 1), allowing continuous interpolation that produces grayscale intermediates. PGM and PPM images are handled component-wise. This tool is ideal for creating animation frames in shell scripts or Netpbm pipelines, though it requires post-processing to split the output stream into individual files.

CAVEATS

Inputs must match exactly in size and maxval; otherwise, pnminterp fails. Outputs multiple concatenated images to stdout—use tools like pnmsplit to separate. PBM interpolation yields grayscale results, not binary.

HISTORY

Part of the Netpbm suite, developed by Jef Poskanzer starting in the early 1990s. Cubic interpolation added in later versions for enhanced quality. Maintained as open-source for Unix-like systems.

SEE ALSO

pnm(1), pgm(5), ppm(5), pnmsplit(1), pnmmix(1)

Copied to clipboard