pamdepth
changes image bit depth
TLDR
Reduce to 8-bit (maxval 255)
$ pamdepth [255] [input.pam] > [output.pam]
Promote to 16-bit (maxval 65535)$ pamdepth [65535] [input.pam] > [output.pam]
Reduce to 1-bit (black-and-white)$ pamdepth [1] [input.pam] > [output.pam]
Read from stdin via pipe$ pnmtopam [input.ppm] | pamdepth [255] > [output.pam]
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
sudo dnf install netpbm
sudo pacman -S netpbm
sudo apk add netpbm
sudo zypper install netpbm
brew install netpbm
nix profile install nixpkgs#netpbm
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
pnmdepth(1), pamrecolor(1), netpbm(1)
