mike42 / escpos-php

PHP library for printing to ESC/POS-compatible thermal and impact printers
Other
2.51k stars 855 forks source link

TM-T88III - Strange issue with dithered image (see photos) #1092

Open DOCaCola opened 2 years ago

DOCaCola commented 2 years ago

I experience a strange issue when trying to print more "complex" images. I have attached two image files, one is a dithered version and one is a non-dithered version. The non-dithered version seems to print fine every time, while the dithered version is distorted. I have attached photos of the result.

IMG_4105 IMG_4106

My setup: I have a TM-T88III connected to a raspberry pi via usb-serial adapter. The graphics library being used should be imagemagick. I have to use bitImage() since graphics() doesn't seem to be working.

Here is the relevant code.

$connector = new FilePrintConnector("/dev/serial/by-id/usb-067b_2303-if00-port0"); $profile = CapabilityProfile::load("TM-T88III");
$printer = new Printer($connector, $profile); $printer -> initialize(); $tux = EscposImage::load('dithered.png', false); $printer -> bitImage($tux, Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT); $printer -> feed(); $printer -> cut(); $printer -> close();

notdithered dithered

DOCaCola commented 2 years ago

I did some more testing. Using the 'native' image library results in the exact same issue. I also cropped the dithered tux image at the top and the same split in the head appears as when i print the uncropped version.

ditheredcropped IMG_4107

DOCaCola commented 2 years ago

I have output the data generated by escpos-php to a file. What is being sent to the printer appears to be correct. My TM-T88III has a native serial port connected via an usb to rs232 adapter. I have tried changing the printer speed between 19200 and 9600 with no difference to what is being printed. Either the printer doesn't interpret the data right or it is some kind of strange issue with the USB-RS232 adapters. I tested two Adapters with an Prolific and a FTDI (genuine) chipset both showing exact the same output.

Hex Workshop -  Z: private tmp printoutput txt  2021-07-26 22-49-03
DOCaCola commented 2 years ago

I tested with bitImageColumnFormat. Even there, there are issues when instructing EscposImage to generate a dithered image.

$tux = EscposImage::load('tux.png', false); $printer -> bitImageColumnFormat($tux); prints fine

$tux = EscposImage::load('tux.png', true); $printer -> bitImageColumnFormat($tux); garbled output IMG_4108 This is the tux.png i used as input: Tux

DOCaCola commented 2 years ago

I produced an image with 2 pixels height that still give me the pixel shift issue. I will attach it to this post along with the raw output from escpos-php. pixeltest Archiv.zip

Devetec commented 6 months ago

Did you ever figure out how to fix this?

DOCaCola commented 6 months ago

Not really. I have upgraded to a TM-T88V which supports the "graphics" function which works unlike "bitImage" function. Maybe in bitImage mode the data needs some additional escaping when certain bitmap sequences are sent to the printer. The printer might interpret some of these bitmap sequences as some other command. Probably looking at the output of the old official windows drivers would be worth a shot for this. Comparing what they send over rs232 compared to escpos-php