star-micronics / star-cloudprnt-for-woocommerce

Print to Star CloudPRNT compatible printers from WooCommerce
MIT License
10 stars 8 forks source link

Requirements for PNG/JPEG print #17

Closed blacktrs closed 2 years ago

blacktrs commented 3 years ago

Is there a possibility to extend this plugin to print JPG or PNG images and what exactly requirements for that images could be?

Lozrus commented 3 years ago

Printing images from the media library is something that we have on the list of potential future features, so we are definitely aware that some users would find it useful.

We would need to depend on a PHP image manipulation library such as libGD in order to load and image and read the pixel information so that we can convert that into Star printer command data. I worry about depending on a library that will not be available on all servers, but we could potentially just disable the option if the correct dependencies are not available.

Star can also offer an HTML based printing service (currently under free beta), which can be integrated with WordPress/WooCommerce quite easily via an email bridge. This would give you immediate access to printing images.

daniel-vacic commented 3 years ago

Thank you @Lozrus, I work with @taras-chr - we created a multi-location order management solution for clients so we are keen to invest time to implement image printing. Is there anything else you could suggest that would help us?

Currently, our client has 6 restaurants and we need to be able to edit the design of the receipt printing to increase readability and decrease mistakes.

daniel-vacic commented 3 years ago

@Lozrus here is some more information >

Our food clients use the MC3 Printers to print orders automatically.

As our system is based on woocommerce, we used the star woocommerce plugin as a starting point. We then extended it to handle our client multi-location requirements. In short, we can connect multiple printers to a single website. We automatically trigger printing at a specific location when an order changes to a processing status.

At present, the printing solution is working successfully at the two locations for Monkey King, but we have some limitations that we were looking to address.

The Problem

Currently, the printer can only handle two font sizes. This prevents us from formatting text for optimal readability in a restaurant scenario. Either the text is too small, so the kitchen staff, who generally have eyesight problems can't read the order or too large, and the text extends across several lines. This means that food preparation error rates are higher than usual. Monkey King Thai would like to implement our solution in more locations but they would like the receipt issues addressed before they do so.

The second is one of brand identity, we are having trouble creating a clean design that matches the visual identity of our clients or our system.

What we have tested

So, we had the idea of converting the orders to an image, and then sending them to the printer. We were able to successfully print an image at a maximum of 430px and lower. We tried to set the image to the 80mm pixel width of 573px but found that the receipts stayed in the queue and did not print. During our testing, we found that the file size did not necessarily impact the printing rather the width of the image did.

The other strange thing is that no matter the width of the image the receipts came out the same height. Suggesting that there may be some limitations we are not aware of.

We have built most of the integrations and plugins ourselves and are happy to be pointed in the right direction.

IMG_2696

We spoke to the Star team in Australia and they suggested we post our issue here

Lozrus commented 3 years ago

@thegrowthproject

Thanks for the more detailed explanation, I really understand the situation better now. Initially I thought that you just wanted to print a different top/bottom of page logo from an image in the Media library. It looks like you've achieved a lot already.

Basically, you are right, the mC-Print models do support receiving png images directly via the CloudPRNT protocol, but there is a size limitation. Being an embedded device, the main issue is limited RAM. Of course, PNG's are compressed, but they need to be fully decoded by the printer in order to be rendered to the print head. a typical 24 or 32 bit per pixel image quickly fills that RAM. PNGs are therefore only useful for very short print jobs on the mC-Print models. But there are several options:

daniel-vacic commented 3 years ago

You're welcome and thank you @Lozrus for the detailed answer.@taras-chr and I will chat about the options and keep you posted.

Lozrus commented 3 years ago

@thegrowthproject & @taras-chr Thanks, I'm interested to see how you get on, and please let us know if you need any more details.

blacktrs commented 3 years ago

Hi @Lozrus, We've implemented cputil method but there is some problem with printing of .bin files. The util is successfully converting png images into command files but printer doesn't print it however process going right and with no any errors. Can you suggest something? Do you need more details? Thanks.

Lozrus commented 3 years ago

@taras-chr The first points to check are:

Also, if the printer is on the same network as your development system, then you can test your resulting binary data by using a utility like netcat to send if directly to your printer on port 9100. This can be helpful just to ensure that your resulting binary data is correct. e.g.: cat data.bin | nc -N [printerIP] 9100

daniel-vacic commented 3 years ago

hi @Lozrus We have successfully printed a receipt but > it only prints to half of the receipt width > any ideas on how we could fix this?

Thank you

IMG_3054

@taras-chr

Lozrus commented 3 years ago

@thegrowthproject & @taras-chr

By default, the conversion is a 1 to 1 mapping of image pixels to printer dots, and the mC-Print3x series can print 576 dots horizontally. So probably just making sure that your source image is 576 pixels wide should be enough.

Also, you can try adding options thermal80 and scale-to-fit to the cputil command line (these should be before the decode option). This will let cputil know that it should target an 80mm wide thermal printer and to scale the source image to fit.

If this still doesn't work, then it may be that the printer itself has some custom print-width settings. This is unlikely - someone would have had to specifically enable these options - but you can check this by printing a self-test page (power the printer on with the FEED switch held for a few seconds), and us the "mC-Print Utility" app (from the App or Play stores) to adjust the settings.

Since it appears that your image is less than 576pixels wide, there will be upscaling, which can potentially cause visible artefacts. Also, any scaling is best avoided when printing any kind of barcode. So I recommend matching the printers native image width if possible for the best results.