pbmtoescp2
Convert PBM image to Epson ESC/P2 format
TLDR
Convert a PBM image to a ESC/P2 printer file
Specify the compression of the output
Specify the horizontal and vertical resolution of the output in dots per inch
Place a formfeed command at the end of the output
SYNOPSIS
pbmtoescp2 [-resolution <DPI>] [-r <DPI>] [-rotate] [-brightness <float>] [-darkness <float>] [-scale <float>] [-xres <DPI>] [-yres <DPI>] [-top <inches>] [-left <inches>] [-no-form-feed] [-verbose] [<pbmfile>]
PARAMETERS
-resolution <DPI>
Sets the printer's resolution in dots per inch (DPI). The printer must support the specified resolution. This option is an alias for -xres and -yres when both are the same.
-r <DPI>
A shorthand alias for -resolution.
-rotate
Rotates the image 90 degrees clockwise before printing. This can be useful for adjusting orientation to fit paper.
-brightness <float>
Adjusts the brightness of the output image. The value should be between 0.0 (darkest) and 1.0 (brightest). Default is 0.5.
-darkness <float>
Adjusts the darkness of the output image. This is an inverse of -brightness, where 0.0 is lightest and 1.0 is darkest. Use either -brightness or -darkness, not both.
-scale <float>
Scales the image by the specified factor. For example, 0.5 for half size, 2.0 for double size.
-xres <DPI>
Sets the horizontal resolution in dots per inch (DPI).
-yres <DPI>
Sets the vertical resolution in dots per inch (DPI). If only -resolution or -xres is given, -yres defaults to the same value.
-top <inches>
Sets the top margin of the printed image in inches. The image will be positioned at this distance from the top edge of the paper.
-left <inches>
Sets the left margin of the printed image in inches. The image will be positioned at this distance from the left edge of the paper.
-no-form-feed
Suppresses the automatic form feed (page eject) command at the end of the output. Useful when printing multiple images on one continuous page or for specific printer setups.
-verbose
Prints status messages and debugging information to standard error during processing.
<pbmfile>
The path to the PBM image file to be converted. If omitted, pbmtoescp2 reads the PBM image data from standard input.
DESCRIPTION
pbmtoescp2 is a command-line utility from the Netpbm image manipulation toolkit. It specializes in converting monochrome Portable BitMap (PBM) image files into a format understood by Epson ESC/P2 compatible printers. ESC/P2 (Epson Standard Code for Printers 2) is a printer control language used by many Epson dot-matrix and inkjet printers.
This command allows users to print PBM images directly to such printers without needing a complex graphical print system, making it ideal for scripting or command-line environments. It typically reads a PBM image from standard input or a specified file and writes the resulting ESC/P2 printer data to standard output, which can then be piped directly to a printer daemon like lpr or redirected to a printer device file.
The utility offers various options to control the output, including setting the printer resolution, rotating the image, adjusting brightness, and defining margins. Since PBM images are inherently black and white, pbmtoescp2 produces monochrome output, suitable for typical dot-matrix or basic inkjet printers. It acts as a bridge between the generic Netpbm image format and the proprietary printer language, enabling efficient and low-level image printing.
CAVEATS
This command is specifically designed for Epson printers that support the ESC/P2 printer control language. It will not work with printers that use other languages (e.g., PostScript, PCL, HP DeskJet).
Output is strictly monochrome, as the input PBM format itself is black and white. While some Epson printers are color, pbmtoescp2 does not utilize color capabilities.
The quality and exact rendering of the output depend heavily on the specific printer model and its supported resolutions. Incorrect resolution settings can lead to distorted or incomplete prints.
For actual printing, the output of pbmtoescp2 must be directed to a printer device or a print spooler (like lpr or lp). It does not handle the physical printing process itself.
STANDARD INPUT/OUTPUT
By default, pbmtoescp2 reads PBM image data from standard input (stdin) if no input file is specified. It writes the generated Epson ESC/P2 printer data to standard output (stdout). This design facilitates piping: for example, anytoppm | pbmtoescp2 | lpr allows converting an image from any format to PBM, then to ESC/P2, and finally sending it to the printer.
PRINTING EXAMPLE
To print a PBM image file named myimage.pbm to your default printer using the lpr command:
pbmtoescp2 -resolution 360 myimage.pbm | lpr
To print an image from another format, convert it first (e.g., using convert from ImageMagick or another Netpbm tool):
convert input.png pbm:- | pbmtoescp2 -resolution 360 | lpr
HISTORY
pbmtoescp2 is an integral part of the widely-used Netpbm image manipulation package. The Netpbm project originated in the late 1980s, primarily developed by Jef Poskanzer, as a set of command-line tools for converting and manipulating various image formats. Its philosophy revolves around using simple, common data formats (PBM, PGM, PPM) as intermediaries. pbmtoescp2 emerged as a specific converter within this suite to address the need for direct printing of monochrome images to popular Epson printers, leveraging their native ESC/P2 language. Its development reflects the pragmatic approach of Netpbm to provide robust, modular utilities for image processing in Unix-like environments.
SEE ALSO
pbm(5), netpbm(1), pnmtoescp2(1), pbmtoepson(1), lpr(1), lp(1)