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

Unable to load an image with a callback function #86

Open
ThomasDmr opened this issue Feb 23, 2024 · 0 comments
Open

Unable to load an image with a callback function #86

ThomasDmr opened this issue Feb 23, 2024 · 0 comments

Comments

@ThomasDmr
Copy link

First of all, thanks for the great work.
I am trying to migrate from escpos and escpos-usb to your driver.
I tried a simple test
async function test() { try { const image = await Image.load('./assets/Packback-black.png'); console.log(image); } catch (error) { console.error('Error loading image:', error); } }

And this successfully loads my image.

Then I tried with a callback function, but this doesn't work :
function test(callback) { Image.load('./assets/Packback-black.png', (err, image) => { if (err) { // Handle error console.error('Error loading image:', err); return; } // Image loaded successfully, call the callback function callback(image); }); }

I get the following error
`C:\Users\thoma\Documents\Computer Projects\LTNG-state-machine\xstate\node_modules\get-pixels\node-pixels.js:126
cb(new Error("Unsupported file type: " + mimeType))
^

Error: Unsupported file type: (err, image) => {
if (err) {
// Handle error
console.error('Error loading image:', err);
return;
}
// Image loaded successfully, call the callback function
callback(image);
}
at doParse (C:\Users\thoma\Documents\Computer Projects\LTNG-state-machine\xstate\node_modules\get-pixels\node-pixels.js:126:10)
at C:\Users\thoma\Documents\Computer Projects\LTNG-state-machine\xstate\node_modules\get-pixels\node-pixels.js:190:7
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3)
`

Like the callback function is interpreted as the "type" parameter of the load function.
But I also tried to add a type but then nothing happens since I don't read the image output.

Any idea what might be the issue ? Do I use the new version wrong ?

Thanks for the help !

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