pstopnm
Convert PostScript to Portable Anymap graphics
TLDR
Convert a PS file to PNM images, storing page N of the input to path/to/fileN.ppm
Explicitly specify the output format
Specify the resolution of the output in dots per inch
SYNOPSIS
pstopnm [options] [inputfile]
PARAMETERS
-resolution
Sets the resolution in DPI (dots per inch) for rendering the PostScript. Common values include 75, 150, 300. Default is usually 75 DPI.
-page
Renders and outputs only the specified page number n from the PostScript document. If omitted, the first page is processed.
-portrait
Forces the PostScript interpreter to render the document in portrait orientation, regardless of its internal settings.
-landscape
Forces the PostScript interpreter to render the document in landscape orientation, regardless of its internal settings.
-mono
Forces the output image to be monochrome (black and white), resulting in a PBM format image.
-gray
Forces the output image to be grayscale, resulting in a PGM format image.
-color
Forces the output image to be color, resulting in a PPM format image. This is often the default if the PostScript content is color.
-forceplain
Outputs the Netpbm image in plain (ASCII) format rather than the default raw (binary) format. Plain format is human-readable but larger.
-eps
Treats the input PostScript file as an Encapsulated PostScript (EPS) file. This often implies a different bounding box handling.
-margin
Adds a margin of val points around the rendered PostScript content.
-gsarg
Passes the specified argument arg directly to the underlying Ghostscript command. Useful for fine-tuning Ghostscript behavior.
-verbose
Prints informative messages about the conversion process to standard error.
DESCRIPTION
pstopnm is a utility from the Netpbm suite that converts PostScript language files into Netpbm image formats: PBM (portable bitmap), PGM (portable graymap), or PPM (portable pixmap). It internally uses a PostScript interpreter, typically Ghostscript (gs), to render the PostScript content into a raster image. This tool is essential for processing PostScript documents in image manipulation workflows, allowing users to preview pages, extract content as images, or convert them for use with other image processing programs. It supports selecting specific pages, adjusting resolution, and forcing output to monochrome, grayscale, or color based on requirements.
CAVEATS
pstopnm relies heavily on the availability and configuration of an external PostScript interpreter, typically Ghostscript (gs). If Ghostscript is not installed or not found in the system's PATH, pstopnm will fail. The quality and features of the output image are limited by the capabilities of the underlying Ghostscript version and its rendering engine.
DEPENDENCY ON GHOSTSCRIPT
pstopnm does not render PostScript itself. It acts as a wrapper, piping the PostScript input to an external interpreter, most commonly Ghostscript (gs), and then processing Ghostscript's output into a Netpbm format. Therefore, Ghostscript must be installed and accessible in the system's PATH for pstopnm to function.
OUTPUT FORMATS
The command can output to three primary Netpbm formats:
PBM (Portable Bitmap): For monochrome (black and white) images.
PGM (Portable Graymap): For grayscale images with varying shades of gray.
PPM (Portable Pixmap): For full-color images.
The choice of output format is often determined by the input PostScript content and the use of options like -mono, -gray, or -color.
HISTORY
pstopnm is part of the Netpbm package, a collection of graphics utilities that originated from PBMplus by Jef Poskanzer in the late 1980s. The Netpbm project's philosophy is to provide simple, portable, and interchangeable command-line tools for image manipulation. pstopnm was developed to bridge the gap between the PostScript document format and the Netpbm raster image formats, leveraging external PostScript interpreters like Ghostscript for the actual rendering process.