LinuxCommandLibrary

pnmtops

Convert PNM image format to PostScript

TLDR

Convert a PNM image to a PS file

$ pnmtops [path/to/file.pnm] > [path/to/file.ps]
copy

Specify the dimensions of the output image in inches
$ pnmtops [[-imagew|-imagewidth]] [imagewidth] [[-imageh|-imageheight]] [imageheight] [path/to/file.pnm] > [path/to/file.ps]
copy

Specify the dimensions of the page the output image resides on in inches
$ pnmtops [[-w|-width]] [width] [[-h|-height]] [height] [path/to/file.pnm] > [path/to/file.ps]
copy

SYNOPSIS

pnmtops [pnmfile] [-equalize] [-forceplain] [-noturn] [-magnification factor] [-xoffset offset] [-yoffset offset] [-width width] [-height height] [-xresolution res] [-yresolution res] [-grayscale] [-color] [-level1] [-level2] [-level3] [-encapsulated] [-printer type] [-setpage] [-dpi dpi] [-rle] [-nofit] [-portrait] [-landscape] [-orientation degrees] [-nomargin] [-pagesize pagesize] [-headerstring string] [-footerstring string]

PARAMETERS

-equalize
    Equalize all colors, effectively applying a gamma correction to the image.

-forceplain
    Generate plain (uncompressed) PostScript output, even if compression is typically used.

-noturn
    Do not rotate the image to fit the page; preserve its original orientation.

-magnification factor
    Magnify the image by the specified numeric factor.

-xoffset offset
    Set the x-offset of the image from the left edge of the page, in points.

-yoffset offset
    Set the y-offset of the image from the bottom edge of the page, in points.

-width width
    Scale the image to the specified width in points.

-height height
    Scale the image to the specified height in points.

-xresolution res
    Set the x-resolution for the output image, in pixels per inch.

-yresolution res
    Set the y-resolution for the output image, in pixels per inch.

-grayscale
    Force grayscale PostScript output, even if the input image is color.

-color
    Force color PostScript output. This option primarily affects printers configured as grayscale.

-level1
    Generate PostScript Level 1 output. This is the default if no printer type is specified.

-level2
    Generate PostScript Level 2 output. This is often the default with specific printer types.

-level3
    Generate PostScript Level 3 output.

-encapsulated
    Generate Encapsulated PostScript (EPS) output, which suppresses the `showpage` command.

-printer type
    Specify the printer type (e.g., 'ps', 'pscolor', 'psgray'), influencing PostScript level and compression.

-setpage
    Include a `setpage` command in the output, which can be useful for some older printers.

-dpi dpi
    Set both x and y resolution to the specified dots per inch (dpi).

-rle
    Explicitly use RLE (Run Length Encoding) compression for the image data in the PostScript output.

-nofit
    Disable automatic fitting of the image onto the page through scaling or rotation.

-portrait
    Force portrait page orientation for the output.

-landscape
    Force landscape page orientation for the output.

-orientation degrees
    Set a custom page orientation in degrees (0, 90, 180, 270).

-nomargin
    Suppress the default 1/2 inch page margins.

-pagesize pagesize
    Set the paper pagesize, e.g., 'letter' or 'a4'.

-headerstring string
    Add a custom string to the PostScript header section.

-footerstring string
    Add a custom string to the PostScript footer section.

pnmfile
    The input PNM file to convert. If omitted, pnmtops reads the image data from standard input.

DESCRIPTION

pnmtops is a utility from the Netpbm project designed to convert a Portable Anymap (PNM) image file into a PostScript file. This conversion is particularly useful for printing images on PostScript-compatible printers or for embedding images into PostScript documents.

The command can handle various PNM formats, including PBM (Portable Bitmap), PGM (Portable Graymap), and PPM (Portable Pixmap). It offers options to control aspects of the output, such as image scaling, positioning on the page, and color handling. Users can specify the PostScript level, the page size, and whether the output should be Encapsulated PostScript (EPS).

pnmtops ensures that the resulting PostScript file is self-contained and suitable for direct printing or inclusion in other PostScript workflows. It intelligently handles image dimensions and can produce both grayscale and color PostScript output based on the input PNM type.

CAVEATS

pnmtops only supports PostScript Level 1, 2, and 3, and may not utilize newer PostScript features.

Color management is basic and does not perform sophisticated color space conversions.

Output quality is directly dependent on the input PNM image's resolution and quality; scaling up significantly can lead to visible pixelation.

INPUT/OUTPUT

pnmtops typically reads a PNM image from standard input if no file is specified, and writes the PostScript output to standard output. This allows for easy piping with other Netpbm utilities or redirection to a file or printer. For example:
pnmfile | pnmtops > output.ps
or
pnmtops input.pnm | lpr

PAGE DIMENSIONS

Unless explicitly specified with options like -width, -height, -xresolution, -yresolution, or -dpi, pnmtops attempts to determine reasonable dimensions for the output based on the input image and default page size. When explicit dimensions are given, they take precedence. The default page size is typically A4 or Letter, depending on the system's locale settings.

HISTORY

pnmtops is a core utility of the Netpbm package, a toolkit of graphics programs for converting, manipulating, and viewing images. The Netpbm project has roots dating back to the early 1990s, evolving from the PBMplus package. pnmtops has been a fundamental component since its early days, providing a reliable way to generate PostScript output from the ubiquitous Netpbm image formats. Its design emphasizes simplicity and robustness, making it a staple for command-line image processing and printing on Unix-like systems. Its development has focused on maintaining compatibility with various PostScript levels and ensuring efficient output for a wide range of printers.

SEE ALSO

pnm(5), pbm(5), pgm(5), ppm(5), pstopnm(1), gs(1), lpr(1)

Copied to clipboard