summaryrefslogtreecommitdiffstats
path: root/upstream/debian-bookworm/man1/pstopnm.1
blob: c6946d23245ea463eca10429915134109e254b60 (plain)
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
\
.\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
.\" Do not hand-hack it!  If you have bug fixes or improvements, please find
.\" the corresponding HTML page on the Netpbm website, generate a patch
.\" against that, and send it to the Netpbm maintainer.
.TH "Pstopnm User Manual" 1 "06 December 2013" "netpbm documentation"

.SH NAME
pstopnm - convert a PostScript file to a PNM image

.UN synopsis
.SH SYNOPSIS

\fBpstopnm\fP

[\fB-stdout\fP]

[\fB-forceplain\fP]

[\fB-help\fP]

[\fB-dpi=\fP\fIdpi\fP]

[\fB-xsize=\fP\fIpixels\fP]
[\fB-ysize=\fP\fIpixels\fP]

[\fB-xborder=\fP\fIfrac\fP]
[\fB-yborder=\fP\fIfrac\fP]
[\fB-landscape\fP]

[\fB-portrait\fP]

[\fB-nocrop\fP]

[\fB-pbm\fP

|\fB-pgm\fP

|\fB-ppm\fP]

[\fB-llx=\fP\fIs\fP]
[\fB-lly=\fP\fIs\fP]
[\fB-urx=\fP\fIs\fP]
[\fB-ury=\fP\fIs\fP]

[\fB-verbose\fP]

[\fB-xmax=\fP\fIpixels\fP]
[\fB-ymax=\fP\fIpixels\fP]

[\fB-textalphabits=\fP{\fB1\fP,\fB2\fP,\fB4\fP}]


\fIpsfile\fP[\fB.ps\fP]

.SH OPTION USAGE
.PP
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.

.UN description
.SH DESCRIPTION
.PP
This program is part of
.BR "Netpbm" (1)\c
\&.
.PP
\fBpstopnm\fP 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, \fBpstopnm\fP will fail.
You can see if you have the proper environment by issuing the command
\f(CWgs --help \fP.  If it responds and lists under "Available
Devices" \fBpbm\fP, \fBpbmraw\fP, \fBpgm\fP, \fBpgmraw\fP,
\fBpnm\fP, \fBpnmraw\fP, \fBppm\fP, or \fBppmraw\fP, you're in
business.
.PP
It's important to understand that \fBpstopnm\fP 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 \fBpstopnm\fP really is is a Postscript
renderer - an image generator.  One place you'll notice the difference is
where you expect \f(CWpstopnm | pnmtops\fP to be idempotent (which is not
the case).  There are details on this kind of conversion below.
.PP
\fBpstopnm\fP uses the value of the \fBGHOSTSCRIPT\fP
environment variable as the file name for the Ghostscript program.  If
\fBGHOSTSCRIPT\fP is not set, \fBpstopnm\fP searches your
\fBPATH\fP for a regular file named \fBgs\fP.  If it doesn't find
one, it assumes Ghostscript is in the file \fB/usr/bin/gs\fP.
.PP
\fBpstopnm\fP does not use the Netpbm libraries to generate the
output files, so may not be entirely consistent with most Netpbm
programs.
.PP
\fIpsfile\fP[\fB.ps\fP] is the name of the input file.
\fBpstopnm\fP will add the \fBps\fP to the end of the name you specify if no
file exists by the exact name you specify, but one with \fB.ps\fPadded does.
For Standard Input, use \fB-\fP or just don't give any argument.
.PP
If you use the \fB-stdout \fP option or your input is from Standard
Input, \fBpstopnm\fP outputs images of all the pages as a multi-image file to
Standard Output.  Otherwise, \fBpstopnm\fP creates one file for each page in
the Postscript input.  The files are named as follows: If the input file is
named \fBpsfile.ps\fP, the name of the files will be
\fBpsfile001.ppm\fP, \fBpsfile002.ppm\fP, etc.  The filetype suffix
is \fB.ppm\fP, \fB.pgm\fP, or \fB.pbm\fP, depending on which kind
of output you choose with your invocation options.  If the input file
name does not end in \fB.ps\fP, the whole file name is used in the
output file name.  For example, if the input file is named
\fBpsfile.old\fP, the output file name is \fBpsfile.old001.ppm\fP,
etc.
.PP
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.
.PP
When your input is from Standard Input, you may feed multiple Encapsulated
Postscript documents, one after another, and \fBpstopnm\fP converts every
document and places it in the Standard Output stream as an image.  But if your
input is from a named file, \fBpstopnm\fP expects the file to be an
Encapsulated Postscript file, which means it contains only one Enapsulated
Postscript document.  If the file contains multiple concatenated
documents, \fBpstopnm\fP ignores every document but the first.  This
distinction does not exist for non-EPSF Postscript input
- \fBpstopnm\fP generates an output image for each page of the input
regardless of whether the input is from Standard Input or from a named file.
.PP
Note that you can generate both kinds of files - concatenated EPSF
and multi-page non-EPSF - with \fBpnmtops\fP, selecting with the
\fB-setpage\fP option.
.PP
Each output image contains a rectangular area of the page to which
it pertains.  See 
.UR #dimensions
the Dimensions section
.UE
\& 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.
.PP
It has been reported that on some Postscript Version 1 input,
Ghostscript, and therefore \fBpstopnm\fP, produces no output.  To
solve this problem, you can convert the file to Postscript Version 3
with the program \fBps2ps\fP.  It is reported that the program
\fBpstops\fP does not work.

.UN dimensions
.SS Dimensions
.PP
This section describes what part of the input image gets used in
the output and the dimensions of the output, including borders and
background.
.PP
Note that an output image is associated with a single input page.

\fBpstopnm\fP starts by taking a rectangular area from the input page.
That is called the subject image.
.PP
\fBpstopnm\fP may add borders to the subject image to form what is called
the bordered subject image.
.PP
\fBpstopnm\fP 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.
.PP
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: \fB-llx\fP, \fB-lly\fP,
\fB-urx\fP, and \fB-ury\fP.
.PP
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
\fB-xborder\fP and \fB-yborder\fP.  If \fBpstopnm\fP does not find
a BoundingBox statement in the input, and you don't specify image area
coordinates on the command line, \fBpstopnm\fP uses default values.
If your input is from Standard Input, \fBpstopnm\fP does not use the
BoundingBox values (because of 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.
.PP
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.
.PP
\fBpstopnm\fP fills the role of a Postscript printer.  The PNM image
is a virtual printed page.  \fBpstopnm\fP 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.
.PP
The simplest thing is for you to tell \fBpstopnm\fP exactly what
output device resolution to use, using the \fB-dpi\fP option.  If you
say for example \fB-dpi=300\fP and the bordered subject image is 2
inches by 3 inches, the PNM output will be 600 pixels by 900 pixels.
Using this method, the output device resolution has to be the same in
both directions.
.PP
Or you can set the output image dimensions with \fB-xsize\fP and
\fB-ysize\fP.  For example, if you say \fB-xsize=1200 -ysize=1800\fP and the
bordered subject image is 2 inches wide by 3 inches high, the output image is
1200 by 1800 pixels, with each pixel representing 1/600 inch of input image.
.PP
In the unlikely event that you want different output device resolutions in
the two directions, you could use \fB-xsize\fP and \fB-ysize\fP to do that.
In the above example, if you change \fB-ysize\fP to 900, a pixel still
represents 1/600 inch horizontally, but 1/300 inch vertically.
.PP
If you specify one of \fB-xsize\fP and \fB-ysize\fP and not the
other, \fBpstopnm\fP defaults the other such that the output device
resolution is the same in both directions.
.PP
The "x" and "y" of \fB-xsize\fP and \fB-ysize\fP
refer to the image being printed on the page, not the page.  So if
\fBpstopnm\fP prints it in landscape orientation, "x" would pertain
to the vertical direction on the page, i.e. the vertical direction in the
output PNM image.
.PP
If you specify neither the output size nor the output device
resolution, \fBpstopnm\fP does some weird computation which exists
mainly for historical reasons:
.PP
If you specify \fB-nocrop\fP, \fBpstopnm\fP uses the values of
\fB-xmax\fP and \fB-ymax\fP for the output image dimensions.  These
default to 612 and 792 pixels, respectively.
.PP
The final case, the default, is where you don't specify any size or
resolution options or \fB-nocrop\fP.  This is the most complicated
case.  In this case, \fBpstopnm\fP first chooses an output device
resolution that would generate the number of pixels indicated by
\fB-xmax\fP and \fB-ymax\fP 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 \fBpstopnm\fP trims the edges of the bordered subject
image to fit the computed output size.


.UN gslimitations
.SS Ghostscript Limitations
.PP
Tests done in 2013 with Ghostscript 8.71 indicate that Ghostscript's
\fBpgmraw\fP output driver has some kind of rounding error that causes the
pixel values to change slightly, and that means \fBpstopnm\fP generates
incorrect output when you have monochrome Postscript input.  But with color
Postscript input, \fBpstopnm\fP uses Ghostscript's \fBppmraw\fP output
driver and generates correct PPM output.


.UN usagenotes
.SS Usage Notes
.PP
There is some good advice on converting to and from Postscript, in the
document
.BR "
Postcript File Conversions" (1)\c
\& by Andrew T. Young.

.UN reversible
.B Reversible Conversion
.PP
If you're trying to do the equivalent of the naive 
\f(CWpnmtops | pstopnm\fP, the following steps will do it.

.nf
\f(CW
    $ pnmtops -nocenter -equalpixels -dpi 72 -noturn testimg.ppm > testimg.ps
    $ pstopnm -xborder=0 -yborder=0 -xsize=\fIXSIZE\fP -ysize=\fIYSIZE\fP \e
        -portrait -stdout -quiet testimg.ps >testimg2.ppm
\fP

.fi

\fIXSIZE\fP and \fIYSIZE\fP above are the image dimensions, which you can
get from testimg.ps like in the following example (the grep, awk and echo
commands are just to help demonstrate how the other commands work - you
wouldn't use those in a program).

.nf
\f(CW
    $ 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)
    $ echo $xysize

     -xsize=227 -ysize=149

    $ pstopnm -xborder=0 -yborder=0 $xysize -portrait ... testimg.ps
\fP

.fi
.PP
Note that Ghostscript bugs can keep this from doing a perfect
reversible conversion.


.UN options
.SH OPTIONS
.PP
In addition to the options common to all programs based on libnetpbm
(most notably \fB-quiet\fP, see 
.UR index.html#commonoptions
 Common Options
.UE
\&), \fBpstopnm\fP recognizes the following
command line options:


.TP
\fB-forceplain\fP
 forces the output file to be in plain (text) format.  Otherwise,
it is in raw (binary) format.  See
.BR "pbm" (1)\c
\&,
etc.  Use this instead of the \fB-plain\fP common option if you need
plain format output.

.TP
\fB-llx=\fP\fIbx\fP
selects \fIbx\fP as the lower left corner x coordinate (in
inches) on the Postscript input page of the subject image.
See 
.UR #dimensions
the Dimensions section
.UE
\&.

.TP
\fB-lly=\fP\fIby\fP
selects \fIby\fP as the lower left corner y coordinate (in inches)
on the Postscript input page of the subject image.
See 
.UR #dimensions
the Dimensions section
.UE
\&.

.TP
\fB-landscape\fP
renders the image in landscape orientation.
.sp
If you specify neither \fB-portrait\fP nor \fB-landscape\fP,
\fBpstopnm\fP chooses the orientation that best fits the image on the
output page.
.sp
Landscape means printed sideways on the page, not printed the long way.
Those are different things if the long edge of the page is the top one.

.TP
\fB-portrait\fP
renders the image in portrait orientation.
.sp
See \fB-landscape\fP.

.TP
\fB-nocrop\fP
This option causes \fBpstopnm\fP to make the output image
exactly the dimensions of the bordered subject image.  By default,
\fBpstopnm\fP makes the output image the dimensions specified by
\fB-xmax\fP and \fB-ymax\fP.  See 
.UR #dimensions
the Dimensions section
.UE
\&.

.TP
\fB-pbm\fP
.TP
\fB-pgm\fP
.TP
\fB-ppm\fP
selects the format of the output file.  By default, all files are
rendered as PPM.

.TP
\fB-stdout\fP
causes output to go to Standard Output instead of to regular
files, one per page (see description of output files above).  Use
\fBpnmsplit\fP to extract individual pages from Standard Output.

.TP
\fB-urx=\fP\fItx\fP
selects \fItx\fP as the upper right corner x coordinate (in
inches) on the Postscript input page of the subject image.  See 
.UR #dimensions
the Dimensions section
.UE
\&.

.TP
\fB-ury=\fP\fIty\fP
selects \fIty\fP as the upper right corner y coordinate (in
inches) on the Postscript input page of the subject image.  See 
.UR #dimensions
the Dimensions section
.UE
\&.


.TP
\fB-verbose\fP
prints processing information to stdout.

.TP
\fB-xborder=\fP\fIfrac\fP 
specifies that the left and right borders added to the subject
image are to be \fIfrac\fP times the subject image width.  The
default value is 0.1.  See 
.UR #dimensions
the Dimensions section
.UE
\&.


.TP
\fB-xmax=\fP\fIxmax\fP
specifies that the output image is to be \fIxmax\fP pixels wide.
The default is 612.  See 
.UR #dimensions
the Dimensions section
.UE
\&.


.TP
\fB-xsize=\fP\fIxsize\fP
specifies that the output image is to be \fIxsize\fP pixels wide.
See 
.UR #dimensions
the Dimensions section
.UE
\&.

.TP
\fB-yborder=\fP\fIfrac\fP
specifies that the top and bottom borders added to the subject
image are to be \fIfrac\fP times the subject image height.  The
default value is 0.1.  See 
.UR #dimensions
the Dimensions section
.UE
\&.


.TP
\fB-ymax=\fP\fIymax\fP
specifies that the output image is to be \fIymax\fP pixels high.
The default is 792.  See 
.UR #dimensions
the Dimensions section
.UE
\&.

.TP
\fB-ysize=\fP\fIysize\fP
specifies that the output image is to be \fIymax\fP pixels high.
See 
.UR #dimensions
the Dimensions section
.UE
\&.

.TP
\fB-dpi=\fP\fIdpi\fP
specifies the output device resolution, in dots per inch, of the
Postscript printer that \fBpstopnm\fP simulates.  This is the number of
PNM pixels \fBpstopnm\fP generates for each inch of image.
See 
.UR #dimensions
the Dimensions section
.UE
\&.
.sp
This option was new in Netpbm 10.21 (March 2004).
     
.TP
\fB-textalphabits=\fP{\fB1\fP,\fB2\fP,\fB4\fP}
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 \fBpnmtops\fP use less CPU
time.
.sp
Pstopnm uses Ghostscript's \fBTextAlphaBits\fP parameter for this.
.sp
The default is 4.
.sp
This option was new in Netpbm 10.53 (December 2010).  Older versions of
\fBpstopnm\fP do no antialiasing.




.UN limitations
.SH LIMITATIONS
.PP
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:

.nf
    pstopnm -xborder 0 -yborder 0 -portrait -nocrop file.ps

.fi
.PP
Additional options may be needed if the document is supposed to be
rendered on a medium different from letter-size paper.

.UN seealso
.SH SEE ALSO

\fBgs\fP,
.BR "pnmtops" (1)\c
\&,
.BR "psidtopgm" (1)\c
\&,
.BR "pbmtolps" (1)\c
\&,
.BR "pbmtoepsi" (1)\c
\&,
.BR "pnmsplit" (1)\c
\&,
\fBpstofits\fP



.UN copyright
.SH COPYRIGHT
.PP
Copyright (c) 1992 Smithsonian Astrophysical Observatory
.PP
PostScript is a Trademark of Adobe Systems Incorporated.


.UN author
.SH AUTHOR
.PP
Alberto Accomazzi, WIPL, Center for Astrophysics.
.SH DOCUMENT SOURCE
This manual page was generated by the Netpbm tool 'makeman' from HTML
source.  The master documentation is at
.IP
.B http://netpbm.sourceforge.net/doc/pstopnm.html
.PP