Replace ppmquantall Safely with pnmquantall
You will replace the obsolete ppmquantall name with pnmquantall, quantise several Netpbm images against one shared colour map, and keep the original files intact while you test. Allow about 10 minutes if Netpbm is already installed.
The route
Jump straight to the step you need, or tick off Done means at the end.
What changed
ppmquantall is not a separate implementation on a current Netpbm system. Its manual says it was replaced by pnmquantall in Netpbm 10.58, released in March 2012. The rename reflects that the program handles all Netpbm input formats, not only PPM. On this machine, the installed package is netpbm 2:11.05.02-1.1build1, and /usr/bin/ppmquantall is a symbolic link to pnmquantall.
There is no configuration migration and no service to restart. Use the new name in shell scripts and documentation. The command needs an ordinary user account when the input files are writable by that account. It does not need sudo.
Checkpoint 1: confirm the replacement
Check the installed package and both command names:
dpkg-query -W -f='${Package} ${Version}\n' netpbm
command -v pnmquantall
command -v ppmquantall
ls -l "$(command -v ppmquantall)"
pnmquantall -version
On the tested installation, the last command reports Netpbm 11.5.2 through the helper programs it runs. The link check should show that the old name resolves to the new executable. If pnmquantall is missing, stop here and install or repair Netpbm using your distribution's normal package process. Do not replace the command with an unverified script.
Checkpoint 2: understand the input and output
The syntax is:
pnmquantall [-ext extension] ncolors netpbm_file...
ncolors is the target number of colours shared by all the files in that invocation. The files can be Netpbm images, rather than only PPM files. Give at least one input file. A command such as pnmquantall 256 frame-01.ppm frame-02.ppm asks the program to choose a common palette of up to 256 colours and remap both images to it.
There is a dangerous default: without -ext, the program overwrites each input file. That change is not reversible unless you have a backup or can recreate the images. The command writes results to the files, not to standard output, so redirecting its output does not create a safe copy.
Checkpoint 3: make a non-destructive test
Use -ext while learning the command or processing valuable images:
pnmquantall -ext quant 256 frame-01.ppm frame-02.ppm
pnmfile frame-01.ppm frame-01.ppmquant
pnmfile frame-02.ppm frame-02.ppmquant
The output keeps the input basename and appends the extension text. With the installed Netpbm version, frame-01.ppm produces frame-01.ppmquant; there is no extra dot inserted before quant. Choose an extension that makes the relationship obvious and does not collide with an existing file.
Expected verification output identifies each file as a Netpbm image and shows its dimensions and maximum sample value, for example:
frame-01.ppm: PPM raw, 1920 by 1080 maxval 255
frame-01.ppmquant: PPM raw, 1920 by 1080 maxval 255
The original and generated files should both exist after this test. Compare them with an image viewer or a checksum when you need to confirm that the generated file is the one you intend to keep:
sha256sum frame-01.ppm frame-01.ppmquant
Use the old name only for compatibility
A legacy script can continue to call ppmquantall on this installation because it is an alias for pnmquantall. Updating the script is still worthwhile: it makes the supported name clear and avoids depending on the compatibility link on another system.
pnmquantall -ext quant 256 frame-01.ppm frame-02.ppm
Do not abbreviate -ext or place it after the colour count. This program has its own argument rules rather than the usual Netpbm option handling. Keep the option first, then the extension, then the colour count and input paths.
When to use the lower-level tools
pnmquantall is a convenience wrapper around pnmcolormap and pnmremap. It is useful when the same collection of images should share a palette. If you need control over how the palette is built or how each image is remapped, run those tools yourself. That also gives you access to their individual options.
Do not confuse a shared palette with identical-looking output at every target size. Quantisation reduces the available colours, so gradients and photographs may show visible changes. Keep the originals until you have checked representative images at their intended display size.
Common failures and recovery
- Not enough arguments: supply a colour count and at least one readable Netpbm file. The program does not accept an empty input list.
- Unexpected overwrite: stop using the command and restore the originals from backup. There is no undo option in
pnmquantall. For the next run, add-ext checkedbefore the colour count. - Missing output: check the exact appended name. The extension is text appended to the complete input filename, such as
photo.ppmcheckedfor-ext checked. - Wrong file type: run
pnmfileon every input first. Convert unsupported formats to Netpbm files using an appropriate, separately verified Netpbm converter. - Insufficient permissions: process a copy in a directory you own. Adding
sudocan create root-owned output and does not repair a bad path or invalid image.
Done means
pnmquantall -versionruns and reports the installed Netpbm build.- Your script or notes use
pnmquantall, not the obsolete name. - You used
-extfor the first run and verified the generated files withpnmfile. - You have kept a backup before any run that omits
-ext.