Reduce the depth (i.e. color resolution) in an image. More information: https://netpbm.sourceforge.net/doc/pamdepth.html.
pamdepth maxval path/to/image.pbm > path/to/file.pbm