bit-image.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /* Example print-outs using the older bit image print command */
  3. require __DIR__ . '/../vendor/autoload.php';
  4. use Mike42\Escpos\Printer;
  5. use Mike42\Escpos\EscposImage;
  6. use Mike42\Escpos\PrintConnectors\FilePrintConnector;
  7. $connector = new FilePrintConnector("php://stdout");
  8. $printer = new Printer($connector);
  9. try {
  10. $tux = EscposImage::load("resources/tux.png", false);
  11. $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");
  12. $printer -> bitImage($tux);
  13. $printer -> text("Regular Tux (bit image).\n");
  14. $printer -> feed();
  15. $printer -> bitImage($tux, Printer::IMG_DOUBLE_WIDTH);
  16. $printer -> text("Wide Tux (bit image).\n");
  17. $printer -> feed();
  18. $printer -> bitImage($tux, Printer::IMG_DOUBLE_HEIGHT);
  19. $printer -> text("Tall Tux (bit image).\n");
  20. $printer -> feed();
  21. $printer -> bitImage($tux, Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT);
  22. $printer -> text("Large Tux in correct proportion (bit image).\n");
  23. } catch (Exception $e) {
  24. /* Images not supported on your PHP, or image file not found */
  25. $printer -> text($e -> getMessage() . "\n");
  26. }
  27. $printer -> cut();
  28. $printer -> close();