rubyepsonescposzpl-ii

How to send color images with ESC/POS?


I have an Epson CW-C6000 that I'm trying to control with ESC commands. I've gotten text to print, so I know I have the IP address, port, etc correct but cannot for the life of me get an image printed.

Here is my code (running from a Ruby on Rails server, with most of the image truncated):

streamSock = TCPSocket.new( "X.X.X.X", 9100 )
str = "~DYR:PRODIMG,B,P,183208,0,89504E470D...4AE426082" + "^XA" + "^FO150,150^IMR:PRODIMG.PNG^FS" + "^XZ"
streamSock.send( str , 0)
streamSock.close

The image is a .png I converted to hexadecimal with this site: http://tomeko.net/online_tools/file_to_hex.php?lang=en

I'm mostly using page 10 of this PDF for reference: https://files.support.epson.com/pdf/pos/bulk/esclabel_apg_en_forcw-c6000series_reve.pdf

Does anyone have a hint? Epson support staff was spectacularly unhelpful.

Also I'm sorry if my formatting is bad; I'm new here and will happily edit my post if something is wrong.


Solution

  • Alright I finally got it working. The command for printing a color .PNG is this:

    ~DYE:[Image Name].PNG,p,p,[Image Size],0,:B64:[Base64 String]:[CRC]
    

    Things that tripped me up:

    -You seem to need the .PNG extension on the file name, even though the Epson manual doesn't show that.

    -[Image Size] is the number of characters in the Base64 string, even though the Epson manual says it should be the size of the original .PNG image file. If this is wrong the printer will hang and no longer accept input of any kind until restarted.

    -There may be other options, but I could only get it working with a CRC of the hex CRC-16/XMODEM type.

    Thanks to K J for his/her suggestions and coming along with me!