pamvalidate - validate Netpbm image format
This program is part of Netpbm(1).
pamvalidate copies a Netpbm image from Standard Input to Standard Output, except that if there are certain violations of the image format in the input, pamvalidate fails without producing any output.
This is most useful in a pipeline, before a stage you don't want to start working on Netpbm input until it knows it can get all the way through it. For example, assume you are converting PPM images to PNG and you don't want to produce a partial PNG file under any circumstance. If you just use pnmtopng, and the PPM input is truncated halfway through the raster, pnmtopng fails, but also produces about half of a PNG file. To prevent that, pass your PPM input through pamvalidate on its way to pnmtopng. Then, pamvalidate will fail, and consequently the pipeline will fail, before pnmtopng has seen any input and therefore before pnmtopng has produced any output.
These are the kinds of format violations pamvalidate detects:
This program works on multi-image streams, producing a corresponding output stream.
See pamfix for a way to salvage an invalid Netpbm image stream.