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

Failed to load image #1225

Closed
byeinsomnia opened this issue Nov 11, 2022 · 1 comment
Closed

Failed to load image #1225

byeinsomnia opened this issue Nov 11, 2022 · 1 comment

Comments

@byeinsomnia
Copy link

Hello,
I'm a beginner in coding. I'm trying to print a picture on my thermal printer but i have some error like this :
Fatal error: Uncaught Exception: Failed to load image. in D:\xampp\htdocs\tes\src\Mike42\Escpos\GdEscposImage.php:63 Stack trace: #0 D:\xampp\htdocs\tes\src\Mike42\Escpos\GdEscposImage.php(51): Mike42\Escpos\GdEscposImage->readImageFromGdResource(Object(GdImage)) #1 D:\xampp\htdocs\tes\src\Mike42\Escpos\EscposImage.php(152): Mike42\Escpos\GdEscposImage->loadImageData('tux.png') #2 D:\xampp\htdocs\tes\src\Mike42\Escpos\Printer.php(461): Mike42\Escpos\EscposImage->toRasterFormat() #3 D:\xampp\htdocs\tes\print_struk.php(19): Mike42\Escpos\Printer->bitImage(Object(Mike42\Escpos\GdEscposImage)) #4 {main} thrown in D:\xampp\htdocs\tes\src\Mike42\Escpos\GdEscposImage.php on line 63

Here my code ,
`<?php
error_reporting(E_ALL & ~E_NOTICE);
require 'autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\EscposImage;
use Mike42\Escpos\CapabilityProfiles\SimpleCapabilityProfile;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\GdEscposImage;

$logo = EscposImage::load("tux.png", false);
$variabel = explode('|',$_GET['variabel']);
$profile = SimpleCapabilityProfile::getInstance();
$connector = new WindowsPrintConnector("smb://localhost/88 Printer");
$printer = new Printer($connector, $profile);
$printer->bitImage($logo);
/* Text */
$printer -> feedReverse(5);
$printer -> setJustification(Printer::JUSTIFY_CENTER);
$printer -> selectPrintMode(Printer::MODE_FONT_B);
$printer -> text('No Antrian Anda : '."\n\n");
$printer -> selectPrintMode(Printer::MODE_FONT_A);
$printer -> setTextSize(3, 3);
$printer -> text($variabel[2]."\n\n");
$printer -> selectPrintMode(Printer::MODE_FONT_B);
$printer -> setTextSize(2, 1);
$printer -> text($variabel[3]."\n");
$printer -> selectPrintMode(Printer::MODE_FONT_B);
$printer -> text('Sisa Antrian: ' . $variabel[1]."\n");
$printer -> text('Masa Berlaku Tiket: ' . $variabel[4]." jam\n");
$printer -> text('Terima kasih atas kunjungan Anda '."\n");
$printer -> text($variabel[0]."\n");

$printer -> selectPrintMode(Printer::MODE_FONT_B);
$printer -> feed(1);
$printer -> cut();

$printer -> close();
?>`
Anyone can help?
Thank you before

@byeinsomnia
Copy link
Author

this is the solution.
#1007

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

1 participant