Simple image format?

I have an 4096x4096 array of f32's, representing a 4kx4k grayscale image.

Saving space is not important. I would like to minimize dependencies (and avoid pulling in the png crate).

Is there a simple image format I can dump this out to. Here, any image format I can view in the browser is fine. (Despite using a browser, space is not important, as the goal here is mainly local host debugging of what is meant to become WebGL textures).

The simplest is probably the BMP file format. There's a description here.

3 Likes

What about Portable pixmap — Wikipédia

Its used in ray trace in one weekend book for its simplicity

1 Like

That’s the main limiter. As @alice suggests, BMP is the simplest uncompressed bitmap format widely supported by web browsers.

In case you happen to be running a scripted job on Linux and have graphicsmagick or imagemagick installed (some distros install them by default), you could just dump the values as they are (or maybe scale them to 8-bit 0–255 integers) and script *magick to make PNGs or whatever.

1 Like

:+1:

The keyword is "Netpbm":


P.S.: I just re-read the post and saw that browser support is a goal. Not sure if that's achieved by PPM/PGM/PBM.

2 Likes

If that's the goal, you can just dump raw bytes and use an image editor. Something like GIMP will load it just fine (IIRC it calls it a .data file), though without the metadata you'll have to tell it the format information when you open it.

PPM is a very simple one.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.