Skip to content

Latest commit

 

History

History
79 lines (49 loc) · 2.22 KB

escimages.md

File metadata and controls

79 lines (49 loc) · 2.22 KB

escimages

escimages extracts raster images from binary ESC/POS files.

All non-graphical elements of the receipt are ignored, and a pair of files is written (in PBM and PNG format) for each image found in the source file.

Installation

This utility is included with escpos-tools. See the escpos-tools documentation for installation instructions.

Usage

Usage: escimages.php OPTIONS --file 'filename'

 Required options:

  -f, --file FILE             The input file to read.

 Output options:

  -o, --output-dir DIRECTORY  The directory to write output files to.

 Output format:

  Select one or more formats for output. If none is specified, then PNG is used.

  --png                        Write output files in PNG format.
  --pbm                        Write output files in PBM format.

 Other options:
  -h, --help                   Show this help

Example

$ php escimages.php -f receipt-with-logo.bin

The raster image from the input receipt is extracted in PNG format:

receipt-with-logo-img.png

The same binary data, when sent to a printer, renders as below:

$ cat receipt-with-logo.bin > /dev/usb/lp0

receipt-with-logo-small.png

The input file used as an example here was generated by escpos-php, and is available here.

Further conversions

This utility will create raster images only. They can be printed back to a printer via escpos-php, or rendered to other formats with the ImageMagick convert utility.

In some cases, drivers convert text to a series of images before printing. To recover text from this type of receipt, the images from escimage can be stacked and sent through a suitable OCR tool.

For example, using tesseract:

rm *.pbm
php escimages.php -f input.bin --pbm
convert -append *.pbm pbm:- | tesseract - -

See also