Debian Codegraph @

upstream/debian-unstable/man1/pstopnm.1

raw
1 \
2 .\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
3 .\" Do not hand-hack it! If you have bug fixes or improvements, please find
4 .\" the corresponding HTML page on the Netpbm website, generate a patch
5 .\" against that, and send it to the Netpbm maintainer.
6 .TH "Pstopnm User Manual" 1 "21 February 2024" "netpbm documentation"
7
8 .SH NAME
9 pstopnm - convert a PostScript file to a PNM image
10
11 .UN synopsis
12 .SH SYNOPSIS
13
14 \fBpstopnm\fP
15
16 [\fB-stdout\fP]
17
18 [\fB-forceplain\fP]
19
20 [\fB-help\fP]
21
22 [\fB-dpi=\fP\fIdpi\fP]
23
24 [\fB-xsize=\fP\fIpixels\fP]
25 [\fB-ysize=\fP\fIpixels\fP]
26
27 [\fB-xborder=\fP\fIfrac\fP]
28 [\fB-yborder=\fP\fIfrac\fP]
29 [\fB-landscape\fP]
30
31 [\fB-portrait\fP]
32
33 [\fB-nocrop\fP]
34
35 [\fB-pbm\fP
36
37 |\fB-pgm\fP
38
39 |\fB-ppm\fP]
40
41 [\fB-llx=\fP\fIs\fP]
42 [\fB-lly=\fP\fIs\fP]
43 [\fB-urx=\fP\fIs\fP]
44 [\fB-ury=\fP\fIs\fP]
45
46 [\fB-verbose\fP]
47
48 [\fB-xmax=\fP\fIpixels\fP]
49 [\fB-ymax=\fP\fIpixels\fP]
50
51 [\fB-textalphabits=\fP{\fB1\fP,\fB2\fP,\fB4\fP}]
52
53
54 \fIpsfile\fP[\fB.ps\fP]
55
56 .SH OPTION USAGE
57 .PP
58 Minimum unique abbreviation of option is acceptable. You may use
59 double hyphens instead of single hyphen to denote options. You may use
60 white space in place of the equals sign to separate an option name
61 from its value.
62
63 .UN description
64 .SH DESCRIPTION
65 .PP
66 This program is part of
67 .BR "Netpbm" (1)\c
68 \&.
69 .PP
70 \fBpstopnm\fP reads a PostScript or PDF file as input and produces PBM,
71 PGM, or PPM images as output. This program simply uses GhostScript to
72 render a PostScript file with its PNM device drivers. If you don't
73 have GhostScript installed or the version you have installed was not
74 built with the relevant PNM device drivers, \fBpstopnm\fP will fail.
75 You can see if you have the proper environment by issuing the command
76 \f(CWgs --help \fP. If it responds and lists under "Available
77 Devices" \fBpbm\fP, \fBpbmraw\fP, \fBpgm\fP, \fBpgmraw\fP,
78 \fBpnm\fP, \fBpnmraw\fP, \fBppm\fP, or \fBppmraw\fP, you're in
79 business.
80 .PP
81 It's important to understand that \fBpstopnm\fP is a Netpbm image file
82 format converter only in the broadest sense of the word, because Postscript is
83 far from an image file format. What \fBpstopnm\fP really is is a Postscript
84 renderer - an image generator. One place you'll notice the difference is
85 where you expect \f(CWpstopnm | pnmtops\fP to be idempotent (which is not
86 the case). There are details on this kind of conversion below.
87 .PP
88 \fBpstopnm\fP uses the value of the \fBGHOSTSCRIPT\fP
89 environment variable as the file name for the Ghostscript program. If
90 \fBGHOSTSCRIPT\fP is not set, \fBpstopnm\fP searches your
91 \fBPATH\fP for a regular file named \fBgs\fP. If it doesn't find
92 one, it assumes Ghostscript is in the file \fB/usr/bin/gs\fP.
93 .PP
94 \fBpstopnm\fP does not use the Netpbm libraries to generate the
95 output files, so may not be entirely consistent with most Netpbm
96 programs.
97 .PP
98 \fIpsfile\fP[\fB.ps\fP] is the name of the input file.
99 \fBpstopnm\fP will add the \fBps\fP to the end of the name you specify if no
100 file exists by the exact name you specify, but one with \fB.ps\fPadded does.
101 For Standard Input, use \fB-\fP or just don't give any argument.
102 .PP
103 If you use the \fB-stdout \fP option or your input is from Standard
104 Input, \fBpstopnm\fP outputs images of all the pages as a multi-image file to
105 Standard Output. Otherwise, \fBpstopnm\fP creates one file for each page in
106 the Postscript input. The files are named as follows: If the input file is
107 named \fBpsfile.ps\fP, the name of the files will be
108 \fBpsfile001.ppm\fP, \fBpsfile002.ppm\fP, etc. The filetype suffix
109 is \fB.ppm\fP, \fB.pgm\fP, or \fB.pbm\fP, depending on which kind
110 of output you choose with your invocation options. If the input file
111 name does not end in \fB.ps\fP, the whole file name is used in the
112 output file name. For example, if the input file is named
113 \fBpsfile.old\fP, the output file name is \fBpsfile.old001.ppm\fP,
114 etc.
115 .PP
116 Note that the output file selection is inconsistent with most
117 Netpbm programs, because it does not default to Standard Output. This
118 is for historical reasons, based on the fact that the Netpbm formats
119 did not always provide for a sequence of images in a single file.
120 .PP
121 When your input is from Standard Input, you may feed multiple Encapsulated
122 Postscript documents, one after another, and \fBpstopnm\fP converts every
123 document and places it in the Standard Output stream as an image. But if your
124 input is from a named file, \fBpstopnm\fP expects the file to be an
125 Encapsulated Postscript file, which means it contains only one Enapsulated
126 Postscript document. If the file contains multiple concatenated
127 documents, \fBpstopnm\fP ignores every document but the first. This
128 distinction does not exist for non-EPSF Postscript input
129 - \fBpstopnm\fP generates an output image for each page of the input
130 regardless of whether the input is from Standard Input or from a named file.
131 .PP
132 Note that you can generate both kinds of files - concatenated EPSF
133 and multi-page non-EPSF - with \fBpnmtops\fP, selecting with the
134 \fB-setpage\fP option.
135 .PP
136 Each output image contains a rectangular area of the page to which
137 it pertains. See
138 .UR #dimensions
139 the Dimensions section
140 .UE
141 \& for
142 details on what part of the input image goes into the output image and
143 how big it is in the output and what borders and margins are in the
144 output image.
145 .PP
146 It has been reported that on some Postscript Version 1 input,
147 Ghostscript, and therefore \fBpstopnm\fP, produces no output. To
148 solve this problem, you can convert the file to Postscript Version 3
149 with the program \fBps2ps\fP. It is reported that the program
150 \fBpstops\fP does not work.
151
152 .UN dimensions
153 .SS Dimensions
154 .PP
155 This section describes what part of the input image gets used in
156 the output and the dimensions of the output, including borders and
157 background.
158 .PP
159 Note that an output image is associated with a single input page.
160
161 \fBpstopnm\fP starts by taking a rectangular area from the input page.
162 That is called the subject image.
163 .PP
164 \fBpstopnm\fP may add borders to the subject image to form what is called
165 the bordered subject image.
166 .PP
167 \fBpstopnm\fP places the bordered subject image in the center of
168 the output image and clips the edges as necessary to fit the computed
169 output image size.
170 .PP
171 The location of the subject image in the Postscript input page is
172 defined by four numbers, the lower left corner and the upper right
173 corner x and y coordinates. These coordinates are usually specified
174 by the BoundingBox DSC statement (a Postscript comment) in the
175 PostScript file, but they can be overridden by the user by specifying
176 one or more of the following options: \fB-llx\fP, \fB-lly\fP,
177 \fB-urx\fP, and \fB-ury\fP.
178 .PP
179 The presence and thickness of a border to be added to the subject
180 image to form the bordered subject image is controlled by the options
181 \fB-xborder\fP and \fB-yborder\fP. If \fBpstopnm\fP does not find
182 a BoundingBox statement in the input, and you don't specify image area
183 coordinates on the command line, \fBpstopnm\fP uses default values.
184 If your input is from Standard Input, \fBpstopnm\fP does not use the
185 BoundingBox values (because of the technical difficulty of extracting that
186 information and still feeding the file to Ghostscript), so you either
187 have to specify the image area coordinates or take the default.
188 .PP
189 The output image size is a confusing thing. In a Postscript file,
190 things have spatial dimensions. For example, a particular line may be
191 3 centimeters long. A Postscript printer is supposed to print the
192 line 3 centimeters long, using however many pixels that takes, without
193 regard to how big the sheet of paper on which it is printing is. In a
194 PNM image, by contrast, there is no spatial dimension; there are only
195 pixels. You might have a line that is 100 pixels long, but the PNM
196 image says nothing about how long that line should be on a printed
197 page.
198 .PP
199 \fBpstopnm\fP fills the role of a Postscript printer. The PNM image
200 is a virtual printed page. \fBpstopnm\fP must determine how many pixels
201 it will use in the output image to represent an inch of input image,
202 which is the "output device resolution." Think of it as the number of
203 dots per inch the virtual printer prints on the virtual page.
204 .PP
205 The simplest thing is for you to tell \fBpstopnm\fP exactly what
206 output device resolution to use, using the \fB-dpi\fP option. If you
207 say for example \fB-dpi=300\fP and the bordered subject image is 2
208 inches by 3 inches, the PNM output will be 600 pixels by 900 pixels.
209 Using this method, the output device resolution has to be the same in
210 both directions.
211 .PP
212 Or you can set the output image dimensions with \fB-xsize\fP and
213 \fB-ysize\fP. For example, if you say \fB-xsize=1200 -ysize=1800\fP and the
214 bordered subject image is 2 inches wide by 3 inches high, the output image is
215 1200 by 1800 pixels, with each pixel representing 1/600 inch of input image.
216 .PP
217 In the unlikely event that you want different output device resolutions in
218 the two directions, you could use \fB-xsize\fP and \fB-ysize\fP to do that.
219 In the above example, if you change \fB-ysize\fP to 900, a pixel still
220 represents 1/600 inch horizontally, but 1/300 inch vertically.
221 .PP
222 If you specify one of \fB-xsize\fP and \fB-ysize\fP and not the
223 other, \fBpstopnm\fP defaults the other such that the output device
224 resolution is the same in both directions.
225 .PP
226 The "x" and "y" of \fB-xsize\fP and \fB-ysize\fP
227 refer to the image being printed on the page, not the page. So if
228 \fBpstopnm\fP prints it in landscape orientation, "x" would pertain
229 to the vertical direction on the page, i.e. the vertical direction in the
230 output PNM image.
231 .PP
232 If you specify neither the output size nor the output device
233 resolution, \fBpstopnm\fP does some weird computation which exists
234 mainly for historical reasons:
235 .PP
236 If you specify \fB-nocrop\fP, \fBpstopnm\fP uses the values of
237 \fB-xmax\fP and \fB-ymax\fP for the output image dimensions. These
238 default to 612 and 792 pixels, respectively.
239 .PP
240 The final case, the default, is where you don't specify any size or
241 resolution options or \fB-nocrop\fP. This is the most complicated
242 case. In this case, \fBpstopnm\fP first chooses an output device
243 resolution that would generate the number of pixels indicated by
244 \fB-xmax\fP and \fB-ymax\fP from the bordered subject image. Then,
245 based on that resolution, it chooses an output image size that is just
246 large enough to accommodate the subject image (no borders). Remember
247 (above) that \fBpstopnm\fP trims the edges of the bordered subject
248 image to fit the computed output size.
249
250
251 .UN gslimitations
252 .SS Ghostscript Limitations
253 .PP
254 Tests done in 2013 with Ghostscript 8.71 indicate that Ghostscript's
255 \fBpgmraw\fP output driver has some kind of rounding error that causes the
256 pixel values to change slightly, and that means \fBpstopnm\fP generates
257 incorrect output when you have monochrome Postscript input. But with color
258 Postscript input, \fBpstopnm\fP uses Ghostscript's \fBppmraw\fP output
259 driver and generates correct PPM output.
260
261
262 .UN usagenotes
263 .SS Usage Notes
264 .PP
265 There is some good advice on converting to and from Postscript, in the
266 document
267 .BR "
268 Postcript File Conversions" (1)\c
269 \& by Andrew T. Young.
270
271 .UN reversible
272 .B Reversible Conversion
273 .PP
274 If you're trying to do the equivalent of the naive
275 \f(CWpnmtops | pstopnm\fP, the following steps will do it.
276
277 .nf
278 \f(CW
279 $ pnmtops -nocenter -equalpixels -dpi 72 -noturn testimg.ppm > testimg.ps
280 $ pstopnm -xborder=0 -yborder=0 -xsize=\fIXSIZE\fP -ysize=\fIYSIZE\fP \e
281 -portrait -stdout -quiet testimg.ps >testimg2.ppm
282 \fP
283
284 .fi
285
286 \fIXSIZE\fP and \fIYSIZE\fP above are the image dimensions, which you can
287 get from testimg.ps like in the following example (the grep, awk and echo
288 commands are just to help demonstrate how the other commands work - you
289 wouldn't use those in a program).
290
291 .nf
292 \f(CW
293 $ grep "BoundingBox" testimg.ps
294 %%BoundingBox: 0 0 227 149
295
296 $ awk '/%%BoundingBox/ {print $4,$5}' testimg.ps
297 227 149
298
299 $ xysize=$(awk '/%%BoundingBox/ {print "-xsize="$4,"-ysize="$5}' testimg.ps)
300 $ echo $xysize
301
302 -xsize=227 -ysize=149
303
304 $ pstopnm -xborder=0 -yborder=0 $xysize -portrait ... testimg.ps
305 \fP
306
307 .fi
308 .PP
309 Note that Ghostscript bugs can keep this from doing a perfect
310 reversible conversion.
311 .PP
312 PDF is a subset of Postscript, so \fBpstopnm\fP can convert from PDF to
313 Netpbm format, but often produces the wrong size image because of
314 \fBpstopnm\fP's reliance on a BoundingBox DSC statement, which PDF does
315 not have. With pure text PDFs, it works fine. In other cases, you can get
316 better results by converting to general Postscript with the \fBpdf2ps\fP
317 program that comes with Ghostscript. For more information about converting to
318 and from PDF, see
319 .UR index.html#document
320 Document/Graphics Software
321 .UE
322 \&.
323
324
325 .UN options
326 .SH OPTIONS
327 .PP
328 In addition to the options common to all programs based on libnetpbm
329 (most notably \fB-quiet\fP, see
330 .UR index.html#commonoptions
331 Common Options
332 .UE
333 \&), \fBpstopnm\fP recognizes the following
334 command line options:
335
336
337 .TP
338 \fB-forceplain\fP
339 forces the output file to be in plain (text) format. Otherwise,
340 it is in raw (binary) format. See
341 .BR "pbm" (1)\c
342 \&,
343 etc. Use this instead of the \fB-plain\fP common option if you need
344 plain format output.
345
346 .TP
347 \fB-llx=\fP\fIbx\fP
348 selects \fIbx\fP as the lower left corner x coordinate (in
349 inches) on the Postscript input page of the subject image.
350 See
351 .UR #dimensions
352 the Dimensions section
353 .UE
354 \&.
355
356 .TP
357 \fB-lly=\fP\fIby\fP
358 selects \fIby\fP as the lower left corner y coordinate (in inches)
359 on the Postscript input page of the subject image.
360 See
361 .UR #dimensions
362 the Dimensions section
363 .UE
364 \&.
365
366 .TP
367 \fB-landscape\fP
368 renders the image in landscape orientation.
369 .sp
370 If you specify neither \fB-portrait\fP nor \fB-landscape\fP,
371 \fBpstopnm\fP chooses the orientation that best fits the image on the
372 output page.
373 .sp
374 Landscape means printed sideways on the page, not printed the long way.
375 Those are different things if the long edge of the page is the top one.
376
377 .TP
378 \fB-portrait\fP
379 renders the image in portrait orientation.
380 .sp
381 See \fB-landscape\fP.
382
383 .TP
384 \fB-nocrop\fP
385 This option causes \fBpstopnm\fP to make the output image
386 exactly the dimensions of the bordered subject image. By default,
387 \fBpstopnm\fP makes the output image the dimensions specified by
388 \fB-xmax\fP and \fB-ymax\fP. See
389 .UR #dimensions
390 the Dimensions section
391 .UE
392 \&.
393
394 .TP
395 \fB-pbm\fP
396 .TP
397 \fB-pgm\fP
398 .TP
399 \fB-ppm\fP
400 selects the format of the output file. By default, all files are
401 rendered as PPM.
402
403 .TP
404 \fB-stdout\fP
405 causes output to go to Standard Output instead of to regular
406 files, one per page (see description of output files above). Use
407 \fBpnmsplit\fP to extract individual pages from Standard Output.
408
409 .TP
410 \fB-urx=\fP\fItx\fP
411 selects \fItx\fP as the upper right corner x coordinate (in
412 inches) on the Postscript input page of the subject image. See
413 .UR #dimensions
414 the Dimensions section
415 .UE
416 \&.
417
418 .TP
419 \fB-ury=\fP\fIty\fP
420 selects \fIty\fP as the upper right corner y coordinate (in
421 inches) on the Postscript input page of the subject image. See
422 .UR #dimensions
423 the Dimensions section
424 .UE
425 \&.
426
427
428 .TP
429 \fB-verbose\fP
430 prints processing information to stdout.
431
432 .TP
433 \fB-xborder=\fP\fIfrac\fP
434 specifies that the left and right borders added to the subject
435 image are to be \fIfrac\fP times the subject image width. The
436 default value is 0.1. See
437 .UR #dimensions
438 the Dimensions section
439 .UE
440 \&.
441
442
443 .TP
444 \fB-xmax=\fP\fIxmax\fP
445 specifies that the output image is to be \fIxmax\fP pixels wide.
446 The default is 612. See
447 .UR #dimensions
448 the Dimensions section
449 .UE
450 \&.
451
452
453 .TP
454 \fB-xsize=\fP\fIxsize\fP
455 specifies that the output image is to be \fIxsize\fP pixels wide.
456 See
457 .UR #dimensions
458 the Dimensions section
459 .UE
460 \&.
461
462 .TP
463 \fB-yborder=\fP\fIfrac\fP
464 specifies that the top and bottom borders added to the subject
465 image are to be \fIfrac\fP times the subject image height. The
466 default value is 0.1. See
467 .UR #dimensions
468 the Dimensions section
469 .UE
470 \&.
471
472
473 .TP
474 \fB-ymax=\fP\fIymax\fP
475 specifies that the output image is to be \fIymax\fP pixels high.
476 The default is 792. See
477 .UR #dimensions
478 the Dimensions section
479 .UE
480 \&.
481
482 .TP
483 \fB-ysize=\fP\fIysize\fP
484 specifies that the output image is to be \fIymax\fP pixels high.
485 See
486 .UR #dimensions
487 the Dimensions section
488 .UE
489 \&.
490
491 .TP
492 \fB-dpi=\fP\fIdpi\fP
493 specifies the output device resolution, in dots per inch, of the
494 Postscript printer that \fBpstopnm\fP simulates. This is the number of
495 PNM pixels \fBpstopnm\fP generates for each inch of image.
496 See
497 .UR #dimensions
498 the Dimensions section
499 .UE
500 \&.
501 .sp
502 This option was new in Netpbm 10.21 (March 2004).
503
504 .TP
505 \fB-textalphabits=\fP{\fB1\fP,\fB2\fP,\fB4\fP}
506 This controls subsample antialiasing of text. Antialiasing is a form of
507 smoothing that eliminates jagged edges on characters. Subsample antialiasing
508 is a kind of antialiasing that uses subpixels in a box, and the value of this
509 option is the size of that box. 4 gives you the best looking output, while 1
510 causes no antialiasing. Smaller numbers make \fBpnmtops\fP use less CPU
511 time.
512 .sp
513 Pstopnm uses Ghostscript's \fBTextAlphaBits\fP parameter for this.
514 .sp
515 The default is 4.
516 .sp
517 This option was new in Netpbm 10.53 (December 2010). Older versions of
518 \fBpstopnm\fP do no antialiasing.
519
520
521
522
523 .UN limitations
524 .SH LIMITATIONS
525 .PP
526 The program will produce incorrect results with PostScript files that
527 initialize the current transformation matrix. In these cases, page
528 translation and rotation will not have any effect. To render these
529 files, probably the best bet is to use the following options:
530
531 .nf
532 pstopnm -xborder 0 -yborder 0 -portrait -nocrop file.ps
533
534 .fi
535 .PP
536 Additional options may be needed if the document is supposed to be
537 rendered on a medium different from letter-size paper.
538
539 .UN seealso
540 .SH SEE ALSO
541
542 \fBgs\fP,
543 .BR "pnmtops" (1)\c
544 \&,
545 .BR "psidtopgm" (1)\c
546 \&,
547 .BR "pbmtolps" (1)\c
548 \&,
549 .BR "pbmtoepsi" (1)\c
550 \&,
551 .BR "pnmsplit" (1)\c
552 \&,
553 \fBpstofits\fP
554
555
556
557 .UN copyright
558 .SH COPYRIGHT
559 .PP
560 Copyright (c) 1992 Smithsonian Astrophysical Observatory
561 .PP
562 PostScript is a Trademark of Adobe Systems Incorporated.
563
564
565 .UN author
566 .SH AUTHOR
567 .PP
568 Alberto Accomazzi, WIPL, Center for Astrophysics.
569 .SH DOCUMENT SOURCE
570 This manual page was generated by the Netpbm tool 'makeman' from HTML
571 source. The master documentation is at
572 .IP
573 .B http://netpbm.sourceforge.net/doc/pstopnm.html
574 .PP