1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD><TITLE>Pstopnm User Manual</TITLE></HEAD>
<BODY>
<H1>pstopnm</H1>
Updated: 04 July 2011
<BR>
<A HREF="#index">Table Of Contents</A>
<H2>NAME</H2>
pstopnm - convert a PostScript file to a PNM image
<H2 id="synopsis">SYNOPSIS</H2>
<B>pstopnm</B>
[<B>-stdout</B>]
[<B>-forceplain</B>]
[<B>-help</B>]
[<B>-dpi=</b><i>dpi</i>]
[<B>-xsize=</B><I>pixels</I>]
[<B>-ysize=</B><I>pixels</I>]
[<B>-xborder=</B><I>frac</I>]
[<B>-yborder=</B><I>frac</I>]
5~
[<B>-landscape</B>]
[<B>-portrait</B>]
[<B>-nocrop</B>]
[<B>-pbm</B>
|<B>-pgm</B>
|<B>-ppm</B>]
[<B>-llx=</B><I>s</I>]
[<B>-lly=</B><I>s</I>]
[<B>-urx=</B><I>s</I>]
[<B>-ury=</B><I>s</I>]
[<B>-verbose</B>]
[<B>-xmax=</B><I>pixels</I>]
[<B>-ymax=</B><I>pixels</I>]
[<B>-textalphabits=</B>{<b>1</b>,<b>2</b>,<b>4</b>}]
<I>psfile</I>[<B>.ps</B>]
<?makeman .SH OPTION USAGE ?>
<P>Minimum unique abbreviation of option is acceptable. You may use
double hyphens instead of single hyphen to denote options. You may use
white space in place of the equals sign to separate an option name
from its value.
<H2 id="description">DESCRIPTION</H2>
<p>This program is part of <a href="index.html">Netpbm</a>.
<p><b>pstopnm</b> reads a PostScript file as input and produces PBM,
PGM, or PPM images as output. This program simply uses GhostScript to
render a PostScript file with its PNM device drivers. If you don't
have GhostScript installed or the version you have installed was not
built with the relevant PNM device drivers, <B>pstopnm</B> will fail.
You can see if you have the proper environment by issuing the command
<kbd>gs --help </kbd>. If it responds and lists under "Available
Devices" <B>pbm</B>, <B>pbmraw</B>, <B>pgm</B>, <B>pgmraw</B>,
<B>pnm</B>, <B>pnmraw</B>, <B>ppm</B>, or <B>ppmraw</B>, you're in
business.
<p>It's important to understand that <b>pstopnm</b> is a Netpbm image file
format converter only in the broadest sense of the word, because Postscript is
far from an image file format. What <b>pstopnm</b> really is is a Postscript
renderer - an image generator. One place you'll notice the difference is
where you expect <kbd>pstopnm | pnmtops</kbd> to be idempotent (which is not
the case). There are details on this kind of conversion below.
<P><B>pstopnm</B> uses the value of the <B>GHOSTSCRIPT</B>
environment variable as the file name for the Ghostscript program. If
<B>GHOSTSCRIPT</B> is not set, <B>pstopnm</B> searches your
<B>PATH</B> for a regular file named <B>gs</B>. If it doesn't find
one, it assumes Ghostscript is in the file <b>/usr/bin/gs</b>.
<P><B>pstopnm</B> does not use the Netpbm libraries to generate the
output files, so may not be entirely consistent with most Netpbm
programs.
<P><I>psfile</I>[<B>.ps</B>] is the name of the input file.
<B>pstopnm</B> will add the <B>ps</B> to the end of the name you
specify if no file exists by the exact name you specify, but one with
added does. Use <B>-</B> to indicate Standard Input.
<P>If you use the <B>-stdout </B> option, <B>pstopnm</B> outputs
images of all the pages as a multi-image file to Standard Output.
Otherwise, <B>pstopnm</B> creates one file for each page in the
Postscript document. The files are named as follows: If the input
file is named <B>psfile.ps</B>, the name of the files will be
<B>psfile001.ppm</B>, <B>psfile002.ppm</B>, etc. The filetype suffix
is <B>.ppm</B>, <B>.pgm</B>, or <B>.pbm</B>, depending on which kind
of output you choose with your invocation options. If the input file
name does not end in <B>.ps</B>, the whole file name is used in the
output file name. For example, if the input file is named
<B>psfile.old</B>, the output file name is <B>psfile.old001.ppm</B>,
etc.
<P>Note that the output file selection is inconsistent with most
Netpbm programs, because it does not default to Standard Output. This
is for historical reasons, based on the fact that the Netpbm formats
did not always provide for a sequence of images in a single file.
<p>Each output image contains a rectangular area of the page to which
it pertains. See <a href="#dimensions">the Dimensions section</a> for
details on what part of the input image goes into the output image and
how big it is in the output and what borders and margins are in the
output image.
<P>It has been reported that on some Postscript Version 1 input,
Ghostscript, and therefore <B>pstopnm</B>, produces no output. To
solve this problem, you can convert the file to Postscript Version 3
with the program <B>ps2ps</B>. It is reported that the program
<B>pstops</B> does not work.
<a name="dimensions"></a>
<h3>Dimensions</h3>
<p>This section describes what part of the input image gets used in
the output and the dimensions of the output, including borders and
background.
<p>Note that an output image is associated with a single input page.
<b>pstopnm</b> starts by taking a rectangular area from the input page.
That is called the subject image.
<p><b>pstopnm</b> may add borders to the subject image to form what is called
the bordered subject image.
<p><b>pstopnm</b> places the bordered subject image in the center of
the output image and clips the edges as necessary to fit the computed
output image size.
<p>The location of the subject image in the Postscript input page is
defined by four numbers, the lower left corner and the upper right
corner x and y coordinates. These coordinates are usually specified
by the BoundingBox DSC statement (a Postscript comment) in the
PostScript file, but they can be overridden by the user by specifying
one or more of the following options: <B>-llx</B>, <B>-lly</B>,
<B>-urx</B>, and <B>-ury</B>.
<p>The presence and thickness of a border to be added to the subject
image to form the bordered subject image is controlled by the options
<B>-xborder</B> and <B>-yborder</B>. If <B>pstopnm</B> does not find
a BoundingBox statement in the input, and you don't specify image area
coordinates on the command line, <B>pstopnm</B> uses default values.
If your input is from Standard Input, <B>pstopnm</B> does not use the
BoundingBox values (due to the technical difficulty of extracting that
information and still feeding the file to Ghostscript), so you either
have to specify the image area coordinates or take the default.
<p>The output image size is a confusing thing. In a Postscript file,
things have spatial dimensions. For example, a particular line may be
3 centimeters long. A Postscript printer is supposed to print the
line 3 centimeters long, using however many pixels that takes, without
regard to how big the sheet of paper on which it is printing is. In a
PNM image, by contrast, there is no spatial dimension; there are only
pixels. You might have a line that is 100 pixels long, but the PNM
image says nothing about how long that line should be on a printed
page.
<p><b>pstopnm</b> fills the role of a Postscript printer. The PNM image
is a virtual printed page. <b>pstopnm</b> must determine how many pixels
it will use in the output image to represent an inch of input image,
which is the "output device resolution." Think of it as the number of
dots per inch the virtual printer prints on the virtual page.
<p>The simplest thing is for you to tell <b>pstopnm</b> exactly what
output device resolution to use, using the <b>-dpi</b> option. If you
say for example <b>-dpi=300</b> and the bordered subject image is 2
inches by 2 inches, the PNM output will be 600 pixels by 600 pixels.
<p>Or you can set the output image dimensions with <b>-xsize</b> and
<b>-ysize</b>. For example, if you say <b>-xsize=1000 -ysize=1000</b>
and the bordered subject image is 2 inches by 2 inches, the output
image is 1000 by 1000 pixels, with each pixel representing 1/500 inch
of input image.
<p>If you specify one of <b>-xsize</b> and <b>-ysize</b> and not the
other, <b>pstopnm</b> defaults the other such that the output image
has the same aspect ratio as the bordered subject image.
<p>If you specify neither the output size nor the output device
resolution, <b>pstopnm</b> does some weird computation which exists
mainly for historical reasons:
<p>If you specify <b>-nocrop</b>, <b>pstopnm</b> uses the values of
<b>-xmax</b> and <b>-ymax</b> for the output image dimensions. These
default to 612 and 792 pixels, respectively.
<p>The final case, the default, is where you don't specify any size or
resolution options of <b>-nocrop</b>. This is the most complicated
case. In this case, <b>pstopnm</b> first chooses an output device
resolution that would generate the number of pixels indicated by
<b>-xmax</b> and <b>-ymax</b> from the bordered subject image. Then,
based on that resolution, it chooses an output image size that is just
large enough to accommodate the subject image (no borders). Remember
(above) that <b>pstopnm</b> trims the edges of the bordered subject
image to fit the computed output size.
<h3 id="usagenotes">Usage Notes</h3>
<p>There is some good advice on converting to and from Postscript, in the
document <a href="http://mintaka.sdsu.edu/GF/bibliog/latex/PSconv.html">Postcript
File Conversions</a> by Andrew T. Young.
<h4 id="reversible">Reversible Conversion</h4>
<p>If you're trying to do the equivalent of the naive
<kbd>pstopnm | pnmtops</kbd>, the following steps will do it.
<pre>
<kbd>
$ pnmtops -nocenter -equalpixels -dpi 72 -noturn testimg.ppm > testimg.ps
$ pstopnm -xborder=0 -yborder=0 -xsize=<i>XSIZE</i> -ysize=<I>YSIZE</I> \
-stdout -quiet testimg.ps
</kbd>
</pre>
<i>XSIZE</i> and <i>YSIZE</i> above are the image dimensions, which you can
get from .ps file can awk or sed:
<pre>
<kbd>
$ grep "BoundingBox" testimg.ps
%%BoundingBox: 0 0 227 149
$ awk '/%%BoundingBox/ {print $4,$5}' testimg.ps
227 149
$ xysize=$(awk '/%%BoundingBox/ {print "-xsize="$4,"-ysize="$5}' testimg.ps)
$ pstopnm -xborder=0 -yborder=0 $xysize ... testimg.ps
</kbd>
</pre>
<H2 id="options">OPTIONS</H2>
<DL COMPACT>
<DT><B>-forceplain</B>
<DD> forces the output file to be in plain (text) format. Otherwise,
it is in raw (binary) format. See <B><A HREF="pbm.html">pbm</A></B>,
etc.
<DT><B>-llx=</B><I>bx</I>
<DD>selects <I>bx</I> as the lower left corner x coordinate (in
inches) on the Postscript input page of the subject image.
See <a href="#dimensions">the Dimensions section</a>.
<DT><B>-lly=</B><I>by</I>
<DD>selects <I>by</I> as the lower left corner y coordinate (in inches)
on the Postscript input page of the subject image.
See <a href="#dimensions">the Dimensions section</a>.
<DT><B>-landscape</B>
<DD>renders the image in landscape orientation.
<DT><B>-portrait</B>
<DD>renders the image in portrait orientation.
<DT><B>-nocrop</B>
<DD>This option causes <b>pstopnm</b> to make the output image
exactly the dimensions of the bordered subject image. By default,
<b>pstopnm</b> makes the output image the dimensions specified by
<b>-xmax</b> and <b>-ymax</b>. See <a href="#dimensions">the Dimensions
section</a>.
<DT><B>-pbm</b>
<DT><B>-pgm</B>
<DT><B>-ppm</B>
<DD>
selects the format of the output file. By default, all files are
rendered as PPM.
<DT><B>-stdout</B>
<DD>causes output to go to Standard Output instead of to regular
files, one per page (see description of output files above). Use
<B>pnmsplit</B> to extract individual pages from Standard Output.
<DT><B>-urx=</B><I>tx</I>
<DD>selects <I>tx</I> as the upper right corner x coordinate (in
inches) on the Postscript input page of the subject image. See <a
href="#dimensions">the Dimensions section</a>.
<DT><B>-ury=</B><I>ty</I>
<DD>selects <I>ty</I> as the upper right corner y coordinate (in
inches) on the Postscript input page of the subject image. See <a
href="#dimensions">the Dimensions section</a>.
<DT><B>-verbose</B>
<DD>
prints processing information to stdout.
<DT><B>-xborder=</B><I>frac</I>
<DD>specifies that the left and right borders added to the subject
image are to be <I>frac</I> times the subject image width. The
default value is 0.1. See <a href="#dimensions">the Dimensions
section</a>.
<DT><B>-xmax=</B><I>xmax</I>
<DD>specifies that the output image is to be <I>xmax</I> pixels wide.
The default is 612. See <a href="#dimensions">the Dimensions
section</a>.
<DT><B>-xsize=</B><I>xsize</I>
<DD>specifies that the output image is to be <I>xsize</I> pixels wide.
See <a href="#dimensions">the Dimensions section</a>.
<DT><B>-yborder=</B><I>frac</I>
<DD>specifies that the top and bottom borders added to the subject
image are to be <I>frac</I> times the subject image height. The
default value is 0.1. See <a href="#dimensions">the Dimensions
section</a>.
<DT><B>-ymax=</B><I>ymax</I>
<DD>
specifies that the output image is to be <i>ymax</i> pixels high.
The default is 792. See <a href="#dimensions">the Dimensions
section</a>.
<DT><B>-ysize=</B><I>ysize</I>
<DD>specifies that the output image is to be <i>ymax</i> pixels high.
See <a href="#dimensions">the Dimensions section</a>.
<DT><B>-dpi=</b><i>dpi</i>
<DD>specifies the output device resolution, in dots per inch, of the
Postscript printer that <b>pstopnm</b> simulates. This is the number of
PNM pixels <b>pstopnm</b> generates for each inch of image.
See <a href="#dimensions">the Dimensions section</a>.
<p>This option was new in Netpbm 10.21 (March 2004).
<dt><b>-textalphabits=</b>{<b>1</b>,<b>2</b>,<b>4</b>}
<dd>This controls subsample antialiasing of text. Antialiasing is a form of
smoothing that eliminates jagged edges on characters. Subsample antialiasing
is a kind of antialiasing that uses subpixels in a box, and the value of this
option is the size of that box. 4 gives you the best looking output, while 1
causes no antialiasing. Smaller numbers make <b>pnmtops</b> use less CPU
time.
<p>Pstopnm uses Ghostscript's <b>TextAlphaBits</b> parameter for this.
<p>The default is 4.
<P>This option was new in Netpbm 10.53 (December 2010). Older versions of
<b>pstopnm</b> do no antialiasing.
</DL>
<H2 id="limitations">LIMITATIONS</H2>
<P>The program will produce incorrect results with PostScript files that
initialize the current transformation matrix. In these cases, page
translation and rotation will not have any effect. To render these
files, probably the best bet is to use the following options:
<pre>
pstopnm -xborder 0 -yborder 0 -portrait -nocrop file.ps
</pre>
<P>Additional options may be needed if the document is supposed to be
rendered on a medium different from letter-size paper.
<H2 id="seealso">SEE ALSO</H2>
<B>gs</B>,
<B><A HREF="pnmtops.html">pnmtops</A></B>,
<B><A HREF="psidtopgm.html">psidtopgm</A></B>,
<B><A HREF="pbmtolps.html">pbmtolps</A></B>,
<B><A HREF="pbmtoepsi.html">pbmtoepsi</A></B>,
<B><A HREF="pnmsplit.html">pnmsplit</A></B>,
<B>pstofits</B>
<H2 id="copyright">COPYRIGHT</H2>
<p>Copyright (c) 1992 Smithsonian Astrophysical Observatory
<p>PostScript is a Trademark of Adobe Systems Incorporated.
<H2 id="author">AUTHOR</H2>
<p>Alberto Accomazzi, WIPL, Center for Astrophysics.
<HR>
<H2 id="table">Table Of Contents</H2>
<UL>
<LI><A HREF="#synopsis">SYNOPSIS</A>
<LI><A HREF="#description">DESCRIPTION</A>
<LI><A HREF="#options">OPTIONS</A>
<LI><A HREF="#limitations">LIMITATIONS</A>
<LI><A HREF="#seealso">SEE ALSO</A>
<LI><A HREF="#copyright">COPYRIGHT</A>
<LI><A HREF="#author">AUTHOR</A>
</UL>
</BODY>
</HTML>
|