Home / Alt manpages / pnminterp(1)

  • pnminterp(1)
  • User command
  • linux

Replace pnminterp with pamstretch for Image Scaling

Type pnminterp today and you are quietly running pamstretch, its replacement since December 2001. This guide confirms what is actually installed, runs a safe scaling test, and shows what to change in scripts. Allow about ten minutes. You need the Netpbm package, a readable PNM image, and a writable directory for a new output file.

The examples use Netpbm package version 2:11.05.02-1.1build1. The local pnminterp(1) manual confirms the replacement: pamstretch is backward compatible with pnminterp, and also accepts PAM input and transparency channels. That compatibility is the useful result here, not a reason to touch an old input file or rewrite a whole image archive.

1. Check the installed names

Start with read-only checks. They do not need sudo or any other elevated privilege:

$ command -v pnminterp
/usr/bin/pnminterp
$ command -v pamstretch
/usr/bin/pamstretch
$ dpkg-query -W -f='${Package} ${Version}\n' netpbm
netpbm 2:11.05.02-1.1build1

On this installation, pnminterp is a symbolic link to pamstretch. Confirm that locally before relying on it in an automated environment:

$ ls -l /usr/bin/pnminterp
lrwxrwxrwx 1 root root 10 ... /usr/bin/pnminterp -> pamstretch
$ readlink /usr/bin/pnminterp
pamstretch

Checkpoint

If pnminterp is missing but pamstretch exists, use pamstretch directly. If both are missing, stop and install or repair Netpbm through your normal package-management process. Do not copy a binary from another machine.

2. Read the replacement command's syntax

The old name has no useful independent interface on the installed system. The replacement takes a scale factor, followed optionally by an input file. With no input file, the normal Netpbm convention is standard input; write the result to standard output unless you provide a shell redirection.

$ pamstretch --help
pamstretch: Use 'man pamstretch' for help.
$ man pamstretch

The documented forms are pamstretch N [infile], pamstretch -xscale=X [infile], and pamstretch -yscale=Y [infile]. A plain N scales both dimensions by an integer factor. Supplying only -xscale leaves the vertical factor at 1; supplying only -yscale leaves the horizontal factor at 1. The scale values are not percentages and do not name a target width.

3. Scale a PNM into a new file

Keep the source untouched and redirect output to a new pathname. This example doubles both dimensions:

$ pamstretch 2 /path/to/input.pgm > /path/to/input-2x.pgm
$ file /path/to/input-2x.pgm
/path/to/input-2x.pgm: Netpbm image data, size = 640 x 480, rawbits, greymap

The exact file wording depends on the input type. Verify the dimensions and that the output is non-empty. For a 320 by 240 input, a factor of 2 should produce 640 by 480. The command interpolates inserted rows and columns rather than simply copying neighbouring pixels, which is the reason to choose it over a basic enlargement command.

Do not use sudo for ordinary image conversion. If the input is readable and the destination directory is writable by your account, elevated privileges add risk without helping.

4. Scale one direction only

Use the axis-specific options when the output should change in only one direction:

$ pamstretch -xscale=2 /path/to/input.pgm > /path/to/input-wide.pgm
$ pamstretch -yscale=3 /path/to/input.pgm > /path/to/input-tall.pgm
$ file /path/to/input-wide.pgm /path/to/input-tall.pgm
/path/to/input-wide.pgm: Netpbm image data, size = 640 x 240, rawbits, greymap
/path/to/input-tall.pgm: Netpbm image data, size = 320 x 720, rawbits, greymap

The options accept an equals sign or a separate value, and option names may use their shortest unique abbreviations. Spell them in full in scripts so a later option addition cannot change what an abbreviation means. The scale factor must be an integer. For non-integer pixel sizes, the local manual points to pamstretch-gen instead.

5. Avoid the output and edge traps

Shell redirection with > truncates an existing destination before pamstretch starts. That is destructive if the destination contains a useful image. Choose a new name, or create a backup before replacing anything:

$ cp --preserve=all /path/to/output.pgm /path/to/output.pgm.bak
$ pamstretch 2 /path/to/input.pgm > /path/to/output.pgm.new
$ file /path/to/output.pgm.new
$ mv /path/to/output.pgm.new /path/to/output.pgm

The mv is the state-changing step. If conversion fails or the dimensions are wrong, do not run it. Remove the incomplete output.pgm.new and retain the original output; the backup remains available as a further recovery copy. After checking the replacement, remove the backup only as a deliberate, separate action.

By default, pamstretch handles the right and bottom edges without interpolation in one direction. --blackedge interpolates those edges to black. --dropedge drops one source pixel at those edges and can make the output an unusual size. Choose either option only when that edge behaviour is part of the image requirement; do not add it to make an unexplained visual defect disappear.

6. Diagnose failures without guessing

If the old command treats a filename as a scale factor, that is expected: the first positional argument is the factor. Put the number first:

$ pnminterp 2 /path/to/input.pgm > /path/to/output.pgm
$ printf 'exit status: %s\n' "$?"
exit status: 0

A non-zero status means the output is not ready to trust. Check the input path and permissions, then inspect the destination dimensions with file. A very small or malformed PNM can also be rejected before scaling. Do not interpret a successful exit status as proof that the picture looks right; inspect the result with a suitable image viewer or a later Netpbm converter.

For scripts, change the executable name from pnminterp to pamstretch while keeping the scale and input arguments in the same order. Test the changed script with a copy of the input and a new output name. There is no service restart, configuration file or privilege change involved.

Done means

  • The installed package version and command paths were checked.
  • New work uses pamstretch, with pnminterp retained only where compatibility requires it.
  • The scale factor and axis-specific dimensions were verified with file.
  • The source image was not overwritten, and replacement output was staged before mv.
  • Edge options were chosen deliberately, not added as unexplained fixes.
  • No elevated privilege or service disruption was needed.