Back a few decades, I recall on a Solaris system stumbling across a family of commands that convert an image file (jpeg, bmp, etc.) to and from a textual form that described images as pixel arrays and pixels on one line of text each with the red, green, blue as ascii digits. With this, you could easily create, process, and modify images in any language without getting bogged down in the image file specifications.
Can someone give me a lead?
CodePudding user response:
You may want to have a look at the PPM format from the
Now convert to ASCII PPM, everything after the # is my comment:
magick image.png -compress none ppm:
P3 # ASCII PPM signature
3 1 # dimensions are 3x1 pixels
255 # pixels are 8-bit scaled
0 0 0 255 255 255 0 255 0 # black pixel, white pixel, lime green pixel
The above syntax is for writing the PPM file on stdout
. If you want it written to a file, just do:
magick image.png -compress none result.ppm
Obviously it works for BMPs and all other formats too:
magick image.bmp -compress none result.ppm
When you have finished processing your image with assorted tools, you can convert back to a BMP or other format with:
magick image.ppm result.bmp