When I was reading the source code for printer for undocumented commands, I found a command for printing images:
The command for image mode is as the following, followed by the raw image data where each bit corresponds to a pixel:
GS(\x1d) v 0 p wL wH hL hH
, where:
- Width is (wL+256*wH)*8 pixels (because it’s in bytes)
- Height is (hL+256*hH) pixels (because it’s in lines)
There is an upper limit of allowed image size of 9224 bytes (73792 pixels), which when used with full width of 384 dots, can fits a 384*192 image. For the image data, every 8 pixels are grouped in a byte, with the left most pixel being the LSB. Groups are arranged left to right for each line. The image data can be generated with Python:
img_data = PIL.ImageOps.invert(img.convert('L')).convert('1').tobytes()
Results:
- Left: 1st attempt that went terribly wrong due to not adding the header properly
- Middle: several attempts that got the size parameter wrong
- Right: 3 successful attempts (32*32, 64*64, 256*256) with several failed ones in between