Debian Codegraph @

userguide/ppmtoarbtxt.html

raw symbols SCIP
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
2 <html><head><title>Ppmtoarbtxt User Manual</title></head>
3 <body>
4 <h1>ppmtoarbtxt</h1>
5 Updated: 26 November 2014
6 <br>
7 <a href="#index">Table Of Contents</a>
8
9 <h2>NAME</h2>
10 ppmtoarbtxt - generate image in arbitrary text format from PPM image
11
12 <h2 id="synopsis">SYNOPSIS</h2>
13
14 <b>ppmtoarbtxt</b>
15 <i>bodytmpl</i>
16 [<b>-hd</b> <i>headtmpl</i>]
17 [<b>-tl</b> <i>tailtmpl</i>]
18 [<i>ppmfile</i>]
19
20 <h2 id="description">DESCRIPTION</h2>
21
22 <p>This program is part of <a href="index.html">Netpbm</a>.
23
24 <p><b>ppmtoarbtxt</b> generates simple text-based graphics formats based on
25 format descriptions given as input. A text-based graphics format is one in
26 which an image is represented by text (like PNM plain format, but unlike
27 PNM raw format).
28
29 <b>ppmtoarbtxt</b> reads a PPM image as input. For each pixel in the
30 image, <b>ppmtoarbtxt</b> writes the contents of the template file
31 <i>bodytmpl</i>, with certain substitutions based on the value of the
32 pixel, to Standard Output.
33
34 <p>You may also supply a head template file, in which case <b>ppmtoarbtxt</b>
35 generates text from the template file, based on the image dimensions, and
36 includes it in the output before anything else.
37
38 <p>Likewise, you may supply a tail template file to cause text to be placed
39 at the end of the output.
40
41
42 <h3 id="templatefiles">Template Files</h3>
43
44 <p>The text that <b>ppmtoarbtxt</b> generates from a template file is the
45 literal text of the template file, except with substitution specifier replaced
46 with something else. The program recognizes a substitution specifier as
47 text of the form <b>#(</b>...<b>)</b>.
48
49 <p><b>ppmtoarbtxt</b> treats white space in the template files the same as any
50 other characters, placing it in the output, with one exception: If the
51 template file ends with a newline character, <b>ppmtoarbtxt</b> ignores it --
52 it does not include it in the output.
53
54 <p>Many substitution specifiers use format strings (another form of template)
55 to specify the substitution. You should make these format strings as minimal
56 as possible, placing literal text outside the substitution specifier instead
57 of inside the format string. For example,
58
59 <p>Wrong: <kbd>#(flum %%%2.2f 0 1) </kbd>
60
61 <p>Right: <kbd>%#(flum %2.2f 0 1) </kbd>
62
63 <p>The valid substitution specifiers are as follows. Text that has the
64 form of a substitution specifier but is not actually valid (e.g.
65 <b>#(random junk)</b> usually just specifies its literal value, but if it is
66 close enough to something valid, <b>ppmtoarbtxt</b> assumes you made a mistake
67 and fails.
68
69 <p>Useful in a body template, to do substitutions based on a particular pixel:
70
71 <dl compact>
72 <dt><b>#(ired</b><i> format blackref whiteref</i><b>)</b>
73
74 <dd>generates an integer in the range <i>blackref</i> to
75 <i>whiteref</i> in a format specified by <i>format</i> representing the red
76 intensity of the pixel. A red intensity of 0 becomes <i>blackref</i>; a red
77 intensity of maxval becomes <i>whiteref</i>, with the rest linearly
78 interpolated in between.
79
80 <p><i>format</i> is a printf-like format specifier like "%d".
81 <b>ppmtoarbtxt</b> uses as the entire format string to a <b>fprintf</b> POSIX
82 library call whose only other argument is the red itensity as an integer data
83 type. <b>ppmtoarbtxt</b> does not necessarily verify that your format string
84 makes sense; there are values you could specify that could even crash the
85 program. To avoid unexpected behavior, keep format strings simple and
86 hardcoded, and never include a per cent sign or newline.
87
88 <p><b>#(ired)</b> is equivalent to <b>#(ired %d 0 255)</b>.
89
90 <dt><b>#(igreen</b><i> format blackref whiteref</i><b>)</b>
91
92 <dd>Same as <b>#(ired...</b>, but for green.
93
94 <dt><b>#(iblue</b><i> format blackref whiteref</i><b>)</b>
95
96 <dd>Same as <b>#(ired...</b>, but for blue.
97
98 <dt><b>#(ilum</b><i> format blackref whiteref</i><b>)</b>
99
100 <dd>Same as <b>#(ired...</b>, but representing the luminance value
101 (0.299*red + 0.587*green + 0.114*blue) of the pixel.
102
103 <dt><b>#(fred</b><i> format blackref whiteref</i><b>)</b>
104
105 <dd>Same as <b>#(ired...</b>, but generates a floating point number instead
106 of an integer.
107
108 <p>In this case, the second argument to the <b>fprintf</b> that uses
109 <i>format</i> has a double precision floating point data type.
110
111 <p><b>#(fred)</b> is equivalent to <b>#(fred %f 0.0 1.0)</b>.
112
113 <dt><b>#(fgreen </b><i>format blackref whiteref</i><b>)</b>
114
115 <dd>Same as <b>#(fred...</b>, but for green.
116
117 <dt><b>#(fblue </b><i>format blackref whiteref</i><b>)</b>
118
119 <dd>Same as <b>#(fred...</b>, but for blue.
120
121 <dt><b>#(flum </b><i>format blackref whiteref</i><b>)</b>
122
123 <dd>Same as <b>#(fred...</b>, but representing the luminance value
124 (0.299*red + 0.587*green + 0.114*blue) of the pixel.
125
126 <dt><b>#(posx </b><i>format</i><b>)</b>
127
128 <dd>Generates the horizontal position of the pixel, in pixels from the left
129 edge of the image.
130
131 <p>The second argument to the <b>fprintf</b> that uses <i>format</i> has an
132 unsigned integer data type.
133
134 <p><i>format</i> defaults to <b>%u</b>
135
136 <dt><b>#(posy </b><i>format</i><b>)</b>
137
138 <dd>Same as <b>#(width...</b>, but for the vertical position.
139
140 </dl>
141
142 <p>If you use any of the above substitution specifiers in a head or tail
143 template, the result is undefined.
144
145 <p>Useful in a head or tail template, to do substitutions based on whole-image
146 attributes:
147
148 <dl compact>
149 <dt><b>#(width </b><i>format</i><b>)</b>
150
151 <dd>Generates the width in pixels of the image.
152
153 <p>The second argument to the <b>fprintf</b> that uses <i>format</i>
154 has an unsigned integer data type.
155
156 <p><i>format</i> defaults to <b>%u</b>
157
158 <dt><b>#(height </b><i>format</i><b>)</b>
159
160 <dd>Same as <b>#(width...</b>, but for the height of the image.
161
162 </dl>
163
164
165 <h2 id="options">OPTIONS</h2>
166
167 <p>In addition to the options common to all programs based on libnetpbm
168 (most notably <b>-quiet</b>, see <a href="index.html#commonoptions">
169 Common Options</a>), <b>ppmtoarbtxt</b> recognizes the following
170 command line options:
171
172 <dl compact>
173 <dt><b>-hd</b> <i>headtmpl</i>
174
175 <dd>This option specifies a head template (<i>headtmpl</i> is the name of the
176 head template file); it causes <b>ppmtoarbtxt</b> to place the contents of the
177 file named <i>headtmpl</i> at the beginning of the output
178
179 <dt><b>-tl</b> <i>tailtmpl</i>
180
181 <dd>This option specifies a tail template; it is analogous to <b>-hd</b>.
182
183 </dl>
184
185 <h2 id="examples">EXAMPLES</h2>
186
187 <h3>gray inversion</h3>
188
189 <p>Here we generate a PGM plain-format image with gray inversion
190 (like <b>ppmtopgm | pnminvert</b>).
191
192 <p>Contents of our head template file:
193
194 <pre>
195 P2
196 #(width) #(height)
197 255
198 </pre>
199
200 <p>Contents of our body skeleton file:
201
202 <pre>
203 #(ilum %d 255 0)
204 </pre>
205
206 <h3>povray file</h3>
207
208 <p>Here we generate a povray file where each pixel is represented by a
209 sphere at location (x,y,z) = (posx,height-posy,luminance). The color
210 of the sphere is the color of the pixel.
211
212 <p>Contents of our head skeleton:
213
214 <pre>
215 #include "colors.inc"
216 #include "textures.inc"
217 camera {
218 location &lt;#(width) * 0.6, #(height) * 0.7, 80&gt;
219 look_at &lt;#(width) * 0.5, #(height) * 0.5, 0&gt;
220 }
221
222 light_source { &lt;#(width) * 0.5, #(height) * 0.5, 25&gt; color White
223 }
224 </pre>
225
226 <p>Contents of our body skeleton:
227
228 <pre>
229 sphere { &lt;#(posx),#(height)-#(posy),#(ilum %d 0 10)&gt;, 0.5
230 texture {
231 pigment {
232 color rgb &lt;#(fred),#(fgreen),#(fblue)&gt;
233 }
234 finish {
235 phong 1
236 }
237 }
238 }
239 </pre>
240
241 <h2 id="seealso">SEE ALSO</h2>
242
243 <a href="pnmtoplainpnm.html">pnmtoplainpnm</a>
244 <a href="pamtable.html">pamtable</a>
245 <a href="ppm.html">ppm</a>
246
247 <h2 id="history">HISTORY</h2>
248
249 <p><b>ppmtoarbtxt</b> was added to Netpbm in Release 10.14 (March 2003).
250 It existed under the name <b>ppmtotxt</b> since 1995.
251
252 <h2 id="author">AUTHOR</h2>
253
254 Copyright (C) 1995 by Peter Kirchgessner
255
256 <hr>
257 <h2 id="index">Table Of Contents</h2>
258 <ul>
259 <li><a href="#synopsis">SYNOPSIS</a>
260 <li><a href="#description">DESCRIPTION</a>
261 <ul>
262 <li><a href="#templatefiles">Template Files</a>
263 </ul>
264 <li><a href="#options">OPTIONS</a>
265 <li><a href="#examples">EXAMPLES</a>
266 <li><a href="#seealso">SEE ALSO</a>
267 <li><a href="#history">HISTORY</a>
268 <li><a href="#author">AUTHOR</a>
269 </ul>
270 </body>
271 </html>