All options can be abbreviated to their shortest unique prefix. You may use two hyphens instead of one. You may separate an option name and its value with white space instead of an equals sign.
pamarith Reads two PBM, PGM, PPM, or PAM images as input. It performs the specified binary arithmetic operation on the intensity values of their pixels, and produces an output of the same format and (in case of PAM format) tuple type as the first (left) input as output. The two input images must be the same width, height, and depth, but need not be of the same format or maxval.
The output image's maxval is the maximum of the two input maxvals.
If the inputs are graphic images and you want to do arithmetic on them in spite of their having different depths (e.g. a PGM has depth 1, while a PPM has depth 3), run the inputs through pgmtoppm before feeding them to pamarith.
pamarith performs the arithmetic on each pair of sample values of each pair of identically located pixels in the two images, as if maxval was 1.0, black was 0.0, and a linear scale in between. pamarith considers the result to be an intensity in that same scale and represents that intensity in the output image. If the result falls outside of [0..1), pamarith clips it -- i.e. considers it to be zero or the maximum intensity representable in the output.
The "as if" maxval of 1.0 can cause an unexpected result with -multiply. Say your two input images have maxval 255, which means the output image also has maxval 255. Consider a location in the image where the input sample values are 5 and 10. You might think the multiplicative product of those would yield 50 in the output. But pamarith carries out the arithmetic as if the maxvals are 1.0, which means the input sample values are 5/255 and 10/255. It multiplies those together and then rescales to the output maxval, giving a sample value in the output PAM of 50/255.
The operator -difference calculates the absolute value of the difference.
If you want to apply a unary function, e.g. "halve", to a single image, use pamfunc.
pamarith replaced pnmarith in Netpbm 10.3 (June 2002). It is backward compatible with pnmarith except that pnmarith allowed the inputs to be of different formats (and therefore different depths). It did PBM to PGM and PGM to PPM promotion to make it work.
So Netpbm 10.3 introduced a new pnmarith which simply does that promotion and runs pamarith
Also, the original pnmarith did not have the -mean option.