Page 1 of 1

ppm to png and back with least loss

Posted: 2009-11-22T03:23:32-07:00
by jzqrt
Greetings,
recently I've ran into a problem: I need to convert ppm (p3) to [insert image format supported by browsers] and back so that those 2 ppm's would be identical. So far I've found "convert in.ppm -compress none some.png && convert some.png -compress none out.ppm" to output least different ppm, but I need even more precision. Could anyone tell me how to achieve this?
Format, size of the image that ppm will be converted to doesn't matter as long as browsers support it.

Re: ppm to png and back with least loss

Posted: 2009-11-22T20:19:55-07:00
by anthony
As the PPM is the less sophisticated file format the results of a round trip through PNG should be quite good.

However PPM has a number of things defining that format that is not preserved by PNG. These include
  • binary or text mode (-compression none for text)
  • Gziped or not (add .gz suffix to output file)
  • Multiple image sequence (just append the PPM files)
  • depth the the PPM image. IM can read all depths, but can only output bit depths 8, 16 (rounding up)
    There is a proposal to allow the specification of any depth for NetPbm formats. For example so you can output values in range say 0 to 99 (PPM depth 100) but no one has programmed the coder to do this.
See notes in
http://www.imagemagick.org/Usage/formats/#netpbm