Ppmtoarbtxt User Manual(1) | General Commands Manual | Ppmtoarbtxt User Manual(1) |
ppmtoarbtxt - generate image in arbitrary text format from PPM image
ppmtoarbtxt bodytmpl [-hd headtmpl] [-tl tailtmpl] [ppmfile]
This program is part of Netpbm(1).
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 template file bodytmpl, with certain substitutions based on the value of the pixel, to Standard Output.
You may also supply a head template file, in which case ppmtoarbtxt generates text from the template file, based on the image dimensions, and includes it in the output before anything else.
Likewise, you may supply a tail template file to cause text to be placed at the end of the output.
The text that ppmtoarbtxt generates from a template file is the literal text of the template file, except with substitution specifier replaced with something else. The program recognizes a substitution specifier as text of the form #(...).
ppmtoarbtxt treats white space in the template files the same as any other characters, placing it in the output, with one exception: If the template file ends with a newline character, ppmtoarbtxt ignores it -- it does not include it in the output.
Many substitution specifiers use format strings (another form of template) to specify the substitution. You should make these format strings as minimal as possible, placing literal text outside the substitution specifier instead of inside the format string. For example,
Wrong: #(flum %%%2.2f 0 1)
Right: %#(flum %2.2f 0 1)
The valid substitution specifiers are as follows. Text that has the form of a substitution specifier but is not actually valid (e.g. #(random junk) usually just specifies its literal value, but if it is close enough to something valid, ppmtoarbtxt assumes you made a mistake and fails.
Useful in a body template, to do substitutions based on a particular pixel:
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 necessarily verify that your format string makes sense; there are values you could specify that could even crash the program. To avoid unexpected behavior, keep format strings simple and hardcoded, and never include a per cent sign or newline.
#(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).
The second argument to the fprintf that uses format has an unsigned integer data type.
format defaults to %u
If you use any of the above substitution specifiers in a head or tail template, the result is undefined.
Useful in a head or tail template, to do substitutions based on whole-image attributes:
The second argument to the fprintf that uses format has an unsigned integer data type.
format defaults to %u
In addition to the options common to all programs based on
libnetpbm (most notably -quiet, see
Common Options ), ppmtoarbtxt recognizes the following command
line options:
Here we generate a PGM plain-format image with gray inversion (like ppmtopgm | pnminvert).
Contents of our head template 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.
Copyright (C) 1995 by Peter Kirchgessner
This manual page was generated by the Netpbm tool 'makeman' from HTML source. The master documentation is at
26 November 2014 | netpbm documentation |