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.
This utility is included with escpos-tools. See the escpos-tools documentation for installation instructions.
php escimages.php FILE
$ php escimages.php receipt-with-logo.bin
The raster image from the input receipt is extracted:
The same binary data, when sent to a printer, renders as below:
$ cat receipt-with-logo.bin > /dev/usb/lp0
The input file used as an example here was generated by escpos-php, and is available here.
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 input.bin
convert -append *.pbm pbm:- | tesseract - -