LinuxCommandLibrary

escp2topbm

Convert Epson ESC/P 2 raster to PBM

TLDR

Convert a ESC/P2 printer file to a PBM image

$ escp2topbm [path/to/image.escp2] > [path/to/output.pbm]
copy

SYNOPSIS

escp2topbm [--escp2 filename] [--pbm filename] [--width pixels] [--height pixels] [--left pixels] [--top pixels] [--density dpi] [--mode mode] [--help] [--version]

PARAMETERS

--escp2 filename, -e filename
    Read ESC/P2 data from filename. If omitted, read from stdin.

--pbm filename, -p filename
    Write PBM data to filename. If omitted, write to stdout.

--width pixels, -w pixels
    Set image width in pixels.

--height pixels, -h pixels
    Set image height in pixels.

--left pixels, -l pixels
    Set left margin in pixels.

--top pixels, -t pixels
    Set top margin in pixels.

--density dpi, -d dpi
    Set resolution in DPI. Default: 360.

--mode mode, -m mode
    Image type: color, gray, or mono. Default: color.

--help
    Display usage information.

--version
    Print version information.

DESCRIPTION

escp2topbm is a command-line utility from the Gutenprint printing system (formerly GIMP-Print) designed to convert Epson's ESC/P2 raster graphics data streams into PBM (Portable Bitmap) format images.

This tool is invaluable for developers and users debugging Epson printer drivers, analyzing print job raster data, or visualizing the exact bitmap output sent to ESC/P2-compatible printers. ESC/P2 is Epson's proprietary printer control language for high-quality raster printing, supporting color, grayscale, and monochrome modes at resolutions up to 720 DPI or more.

The utility parses ESC/P2 commands embedded in the input stream, extracts raster data while respecting margins, resolution, and mode settings, and renders it as a standard PBM file readable by tools like Netpbm, ImageMagick, or GIMP. By default, it processes color mode data at 360 DPI, but options allow customization for precise reproduction.

Common use cases include piping printer output through escputil for inspection or converting captured print data for archiving. It handles partial streams and ignores non-raster commands, focusing solely on bitmap generation.

CAVEATS

Supports only raster data in ESC/P2 streams; ignores text/fonts/other commands. Large images may require significant memory.

HISTORY

Developed in the late 1990s as part of the GIMP-Print project for Linux/Unix printing support. Integrated into Gutenprint (v5+), with ongoing maintenance for Epson ESC/P2 printers. Widely used in CUPS environments.

SEE ALSO

escputil(1), pbm(5), pnmtopng(1)

Copied to clipboard