mike42 / escpos-php

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

EscposImage dithering #97

Closed SteampunkProfessor closed 8 years ago

SteampunkProfessor commented 8 years ago

You can add the Citizen CBM1000-II to your list. Any chance of adding an Atkinson dither to EscposImage.php? Thans for your worrk, it's fun trying it out.

mike42 commented 8 years ago

I'll leave this open as a feature request.

Could be done with a few loops-

Or could use dithering algo's built in to GD & Imagick-

mike42 commented 8 years ago

As part of the image handling re-write, the raster data is all generated in ImageMagick in a single call, which dithers as a side-effect-

$im -> setformat('pbm');
$im -> getimageblob();

The linked commit contains a challenging public domain sample image, and a code snippet showing how to fall back on the old, slow implementation which performed a threshold.

The output is-

2015-04-dither-example

I'll note that the image quality is still not as good as I would like, but this is simply what Imagick gets us. Any pure PHP image manipulation will be very slow, so you should either pre-process your images or use an alternative utility to render them if you have an image-intensive workflow.

Specifically, if you are printing a lot of images, you should also check out-

SteampunkProfessor commented 8 years ago

Thanks for the update!

On Mon, Apr 25, 2016 at 2:14 AM, Michael notifications@github.com wrote:

Closed #97 https://github.com/mike42/escpos-php/issues/97 via 7029b7b https://github.com/mike42/escpos-php/commit/7029b7bdc5b79dbfc81c2364720187b671e53be7 .

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/mike42/escpos-php/issues/97#event-639283176