Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Printing in Grayscale #1346

Open
gcardozo2809 opened this issue Jul 26, 2024 · 2 comments
Open

Image Printing in Grayscale #1346

gcardozo2809 opened this issue Jul 26, 2024 · 2 comments

Comments

@gcardozo2809
Copy link

Hi,

I am printing an image, and currently, it seems like it just replaces the color with either 1 or 0 for black and white, making the image show just those 2 colors.

However, the printer is capable of more complex grayscale combinations, achieving better results when printing the image directly.

Is this possible already and I'm just missing how to do it? Or is there no capability for more complex color management and it will always just do 1/0 for black/white?

I am using Imagick extension.

Thank you!

@dalpil
Copy link

dalpil commented Aug 20, 2024

Hello!

There's currently no built-in support for multi-tone (true grayscale) image printing in escpos-php, but here's a workaround;

If you have one of the few Epson printers that can output multi-tone prints (TM-T70II, TM-T88V, TM-T88VI or TM-T88VII afaik) then you can use the Epson BmpToRaster utility (under Utilities) to convert your image into a multi-tone .bin-file.

This .bin-file could then be read by your application and sent off to your printer. Here is a short example;

<?php
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
use Mike42\Escpos\Printer;

$connector = new NetworkPrintConnector("printer.example.com", 9100);
$printer = new Printer($connector);

try {
        $multitone_image = file_get_contents("multitone-image.bin");
        $printer->getPrintConnector()->write($multitone_image);
        $printer->cut();

} finally {
        $printer -> close();
}
?>

I just tested the above on a TM-T88V and it came out as expected.


If you are comfortable with using Python I'd suggest taking a look at my own utility for converting images into multi-tone images as well. It will most likely yield better results than BmpToRaster, and it'll run on Linux and Mac as well.

It might also serve as inspiration for anyone else that would like to implement support for multi-tone images in escpos-php.


Related issues: #154, #158

@dalpil
Copy link

dalpil commented Aug 21, 2024

After digging around I found out that Bixolon also has a couple of models that claim to support 16 levels of grayscale, namely the SRP-350plusIII and SRP-350plusV models.

I skimmed through the Command Manual on Bixolon's website, but couldn't find any mention of how to send 4-bit image data to their printers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants