LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

pamdepth

changes image bit depth

TLDR

Reduce to 8-bit (maxval 255)
$ pamdepth [255] [input.pam] > [output.pam]
copy
Promote to 16-bit (maxval 65535)
$ pamdepth [65535] [input.pam] > [output.pam]
copy
Reduce to 1-bit (black-and-white)
$ pamdepth [1] [input.pam] > [output.pam]
copy
Read from stdin via pipe
$ pnmtopam [input.ppm] | pamdepth [255] > [output.pam]
copy

SYNOPSIS

pamdepth maxval [file]

DESCRIPTION

pamdepth rescales the maxval (per-sample resolution) of a Netpbm/PAM image. Increasing the maxval is lossless; decreasing it loses precision but never changes the image's tuple type or width/height.If the input already has the requested maxval, pamdepth copies it through unchanged. Use pamdepth 1 to drop a grayscale image down to bilevel, or pamdepth 65535 to widen an 8-bit image so subsequent processing avoids quantization.

PARAMETERS

MAXVAL

New maxval (1–65535). Each sample is rescaled by the ratio new\maxval / old\maxval; the resulting bit depth is the smallest power of two that holds MAXVAL (e.g. 255 → 8-bit, 65535 → 16-bit).
FILE
Input PAM, PPM, PGM, or PBM image. Defaults to standard input when omitted.

INSTALL

sudo apt install netpbm
copy
sudo dnf install netpbm
copy
sudo pacman -S netpbm
copy
sudo apk add netpbm
copy
sudo zypper install netpbm
copy
brew install netpbm
copy
nix profile install nixpkgs#netpbm
copy

CAVEATS

Reducing maxval truncates precision. To convert between tuple types (e.g. RGB to grayscale), use pamtopnm or related tools, not pamdepth.

HISTORY

pamdepth is part of Netpbm for bit depth conversion.

SEE ALSO

Copied to clipboard
Kai