30 lines
954 B
PHP
30 lines
954 B
PHP
<?php
|
|
/*
|
|
* Example of dithering used in EscposImage by default, if you have Imagick loaded.
|
|
*/
|
|
require __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use Zelda\EscposPhp\Printer;
|
|
use Zelda\EscposPhp\EscposImage;
|
|
use Zelda\EscposPhp\PrintConnectors\FilePrintConnector;
|
|
|
|
$connector = new FilePrintConnector("/dev/usb/lp0");
|
|
$printer = new Printer($connector);
|
|
try {
|
|
/* Load with optimisations enabled. If you have Imagick, this will get you
|
|
a nicely dithered image, which prints very quickly
|
|
*/
|
|
$img1 = EscposImage::load(__DIR__ . '/../resources/tulips.png');
|
|
$printer->bitImage($img1);
|
|
|
|
/* Load with optimisations disabled, forcing the use of PHP to convert the
|
|
pixels, which uses a threshold and is much slower.
|
|
*/
|
|
$img2 = EscposImage::load(__DIR__ . '/../resources/tulips.png', false);
|
|
$printer->bitImage($img2);
|
|
$printer->cut();
|
|
} finally {
|
|
/* Always close the printer! */
|
|
$printer->close();
|
|
}
|