3 comments

1

This library is a little too simple. A true PPM image should be saved using the BT.709 colorspace. This library merely dumps the RGB array given to it to a PPM like formatted file. Seeing as most systems today usually assume a sRGB colorspace (unless told otherwise) you will likely be writing an incorrect format to the PPM file using this library. Just a heads up to anyone trying to use this.

0

Thanks for the feedback. I'm not too familiar with colorspaces. I made this library for visualizing data and I figured 1:1 mapping of data to rgb values makes the most sense.

I'm able to open them with GIMP without any problems and I'm able to convert them into anything I want with ImageMagick.

0

You made me read a lot about color spaces. I added sRGB color space support. I was going to add BT.709 support as you suggested, but AFAIK it has the same curve as sRGB but with a narrower range to allow for peaks. The PPM documentation says

BT.709's range of channel values (16-240) is irrelevant to PPM.

which I interpret as meaning I should still use 0-255. (I could be wrong)

In either case I coded the library in such a way that people can easily plug in their own color space conversion methods if they want.

An interesting thing I learned about sRGB is that it has a linear part and a non-linear part. The dark parts of the image are linear, but the rest of the image has a gamma of 2.4 applied to it.