This program is part of Netpbm.
ppmtoarbtxt generates simple text-based graphics formats based on format descriptions given as input. A text-based graphics format is one in which an image is represented by text (like PNM plain format, but unlike PNM raw format). ppmtoarbtxt reads a PPM image as input. For each pixel in the image, ppmtoarbtxt writes the contents of the skeleton file bodyskl, with certain substitutions based on the value of the pixel, to stdout. The substitutions are as follows:
format is a printf-like format specifier like "%d". ppmtoarbtxt uses as the entire format string to a fprintf POSIX library call whose only other argument is the red itensity as an integer data type. ppmtoarbtxt does not verify that your format string makes sense; there are values you could specify that could even crash the program.
#(ired) is equivalent to #(ired %d 0 255).
In this case, the second argument to the fprintf that uses format has a double precision floating point data type.
#(fred) is equivalent to #(fred %f 0.0 1.0).
If the skeleton file ends with a LF-character, ppmtoarbtxt ignores it -- it does not include it in the output.
Here we generate a PGM plain-format image with gray inversion (like ppmtopgm | pnminvert).
Contents of our head skeleton file:
P2 #(width) #(height) 255
Contents of our body skeleton file:
#(ilum %d 255 0)
Here we generate a povray file where each pixel is represented by a sphere at location (x,y,z) = (posx,height-posy,luminance). The color of the sphere is the color of the pixel.
Contents of our head skeleton:
#include "colors.inc" #include "textures.inc" camera { location <#(width) * 0.6, #(height) * 0.7, 80> look_at <#(width) * 0.5, #(height) * 0.5, 0> } light_source { <#(width) * 0.5, #(height) * 0.5, 25> color White }
Contents of our body skeleton:
sphere { <#(posx),#(height)-#(posy),#(ilum %d 0 10)>, 0.5 texture { pigment { color rgb <#(fred),#(fgreen),#(fblue)> } finish { phong 1 } } }
ppmtoarbtxt was added to Netpbm in Release 10.14 (March 2003). It existed under the name ppmtotxt since 1995.