2015.02.08 19:19 "[Tiff] Add support for 12 and 16 bpp to ppm2tiff", by Ludolf Holzheid

2015.02.11 23:36 "Re: [Tiff] Add support for 12 and 16 bpp to ppm2tiff", by Prophet of the Way

If you want to make a ppm image with an arbitrary maximum color value (maxval), use the Netpbm utility pamdepth. It changes the maxval.

http://netpbm.sourceforge.net/doc/pamdepth.html

$ pamdepth image.ppm 80 > image-80.ppm   # Changes maxval to 80

There is another, cruder method I use to generate test images.

To produce an image with maxval 100, using a conventional image with maxval 255:

$ sed '3s/255/100/' testimg.ppm > newtestimg.ppm

This (usually) produces an invalid image with pixels with values above the maxval. The white pixels (anything brighter than medium gray) as well as strong red, blue, green, etc. ones overflow. A serious program should check for this. If it doesn't, its manual should say so. In this case I recommend a reference to pamvalidate which is the utility which performs this check:

http://netpbm.sourceforge.net/doc/pamvalidate.html

To convert ascii ppm to raw (binary) ppm, use pnmtopnm:

http://netpbm.sourceforge.net/doc/pnmtopnm.html