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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Pstopnm User Manual</title></head>
<body>
<h1>pstopnm</h1>
Updated: 21 February 2024
<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>]
[<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 or PDF 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 <b>.ps</b>added does.
For Standard Input, use <b>-</b> or just don't give any argument.
<p>If you use the <b>-stdout </b> option or your input is from Standard
Input, <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 input. 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>When your input is from Standard Input, you may feed multiple Encapsulated
Postscript documents, one after another, and <b>pstopnm</b> converts every
document and places it in the Standard Output stream as an image. But if your
input is from a named file, <b>pstopnm</b> 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, <b>pstopnm</b> ignores every document but the first. This
distinction does not exist for non-EPSF Postscript input
— <b>pstopnm</b> generates an output image for each page of the input
regardless of whether the input is from Standard Input or from a named file.
<p>Note that you can generate both kinds of files — concatenated EPSF
and multi-page non-EPSF — with <b>pnmtops</b>, selecting with the
<b>-setpage</b> option.
<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.
<h3 id="dimensions">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 (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.
<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 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.
<p>Or you can set the output image dimensions with <b>-xsize</b> and
<b>-ysize</b>. For example, if you say <b>-xsize=1200 -ysize=1800</b> 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.
<p>In the unlikely event that you want different output device resolutions in
the two directions, you could use <b>-xsize</b> and <b>-ysize</b> to do that.
In the above example, if you change <b>-ysize</b> to 900, a pixel still
represents 1/600 inch horizontally, but 1/300 inch vertically.
<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 device
resolution is the same in both directions.
<p>The "x" and "y" of <b>-xsize</b> and <b>-ysize</b>
refer to the image being printed on the page, not the page. So if
<b>pstopnm</b> 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.
<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 or <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="gslimitations">Ghostscript Limitations</h3>
<p>Tests done in 2013 with Ghostscript 8.71 indicate that Ghostscript's
<b>pgmraw</b> output driver has some kind of rounding error that causes the
pixel values to change slightly, and that means <b>pstopnm</b> generates
incorrect output when you have monochrome Postscript input. But with color
Postscript input, <b>pstopnm</b> uses Ghostscript's <b>ppmraw</b> output
driver and generates correct PPM output.
<h3 id="usagenotes">Usage Notes</h3>
<p>There is some good advice on converting to and from Postscript, in the
document <a href="https://aty.sdsu.edu/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>pnmtops | pstopnm</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> \
-portrait -stdout -quiet testimg.ps >testimg2.ppm
</kbd>
</pre>
<i>XSIZE</i> and <i>YSIZE</i> 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).
<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)
$ echo $xysize
-xsize=227 -ysize=149
$ pstopnm -xborder=0 -yborder=0 $xysize -portrait ... testimg.ps
</kbd>
</pre>
<p>Note that Ghostscript bugs can keep this from doing a perfect
reversible conversion.
<p>PDF is a subset of Postscript, so <b>pstopnm</b> can convert from PDF to
Netpbm format, but often produces the wrong size image because of
<b>pstopnm</b>'s reliance on a BoundingBox DSC statement, which PDF does
not have. With pure text PDFs, it works fine. In other cases, you can get
better results by converting to general Postscript with the <b>pdf2ps</b>
program that comes with Ghostscript. For more information about converting to
and from PDF, see
<a href="index.html#document">Document/Graphics Software</a>.
<h2 id="options">OPTIONS</h2>
<p>In addition to the options common to all programs based on libnetpbm
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions">
Common Options</a>), <b>pstopnm</b> recognizes the following
command line options:
<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. Use this instead of the <b>-plain</b> common option if you need
plain format output.
<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.
<p>If you specify neither <b>-portrait</b> nor <b>-landscape</b>,
<b>pstopnm</b> chooses the orientation that best fits the image on the
output page.
<p>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.
<dt><b>-portrait</b>
<dd>renders the image in portrait orientation.
<p>See <b>-landscape</b>.
<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="index">Table Of Contents</h2>
<ul>
<li><a href="#synopsis">SYNOPSIS</a>
<li><a href="#description">DESCRIPTION</a>
<ul>
<li><a href="#dimensions">Dimensions</a>
<li><a href="#gslimitations">Ghostscript Limitations</a>
<li><a href="#usagenotes">Usage Notes</a>
<ul>
<li><a href="#reversible">Reversible Conversion</a>
</ul>
</ul>
<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>
|