-
Notifications
You must be signed in to change notification settings - Fork 850
/
bit-image.php
36 lines (28 loc) · 1.29 KB
/
bit-image.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/* Example print-outs using the older bit image print command */
require __DIR__ . '/../vendor/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\EscposImage;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
try {
$tux = EscposImage::load("resources/tux.png", false);
$printer -> text("These example images are printed with the older\nbit image print command. You should only use\n\$p -> bitImage() if \$p -> graphics() does not\nwork on your printer.\n\n");
$printer -> bitImage($tux);
$printer -> text("Regular Tux (bit image).\n");
$printer -> feed();
$printer -> bitImage($tux, Printer::IMG_DOUBLE_WIDTH);
$printer -> text("Wide Tux (bit image).\n");
$printer -> feed();
$printer -> bitImage($tux, Printer::IMG_DOUBLE_HEIGHT);
$printer -> text("Tall Tux (bit image).\n");
$printer -> feed();
$printer -> bitImage($tux, Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT);
$printer -> text("Large Tux in correct proportion (bit image).\n");
} catch (Exception $e) {
/* Images not supported on your PHP, or image file not found */
$printer -> text($e -> getMessage() . "\n");
}
$printer -> cut();
$printer -> close();