On 20/05/2018 01:39, Dennis Lee Bieber wrote:
On Sat, 19 May 2018 23:14:08 +0100, bartc <b...@freeuk.com> declaimed the
following:


The comments and examples here:
https://en.wikipedia.org/wiki/Netpbm_format, and all actual ppm files
I've come across, suggest the 3 parts of the header (2 parts for P1/P4)
are on separate lines. That is, separated by newlines. The comments are
a small detail that is not hard to deal with.


        Wikipedia is not a definitive document...

http://netpbm.sourceforge.net/doc/ppm.html has
"""
Each PPM image consists of the following:

     A "magic number" for identifying the file type. A ppm image's magic
number is the two characters "P6".
     Whitespace (blanks, TABs, CRs, LFs).
     A width, formatted as ASCII characters in decimal.
     Whitespace.
     A height, again in ASCII decimal.
     Whitespace.
     The maximum color value (Maxval), again in ASCII decimal. Must be less
than 65536 and more than zero.
     A single whitespace character (usually a newline).
"""

I think if you are going to be generating ppm, then the best choice of format, for the widest acceptance, is to separate the header groups with a newline. (As I mentioned my downloaded viewer needs a new line after the first group. My own viewer, which I only threw together the other day to test that benchmark, also expects the newlines. Otherwise I might need to do 5 minutes' coding to fix it.)

(Regarding those benchmarks (https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/mandelbrot.html), as far as I can tell every language generates the ppm file inline (no special ppm library), and they all generate the P4 signature on one line and width/height on the next line.

(Click on any source file and look for "P4". Most do it with less fuss than Python too.))

        That all the ones you've seen have a certain layout may only mean that
the generating software used a common library implementation:
http://netpbm.sourceforge.net/doc/libnetpbm.html

Blimey, it makes a meal of it. I got the impression this was supposed to be a simple image format, and with the line-oriented all-text formats it was.

But it could be worse: they might have used XML.

--
bartc
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to