How does it work in nodejs? The code for demo has been invalid
greenking19 opened this issue · comments
GreenKing19 commented
How does it work in nodejs? The code for de mo has been invalid
I run in Nodejs after prompting "NotFoundException: No MultiFormat Readers were able to detect the code."
What do I need to do? 🤯
Are there any other demo codes? 🤔️
/**
* zxing-js reader🧐
* @param {string} filePath file path 📃
* @returns {string | null}
*/
export const zxingJsReader = async (filePath) => {
const hints = new Map();
const formats = [BarcodeFormat.QR_CODE, BarcodeFormat.DATA_MATRIX /*, ...*/];
hints.set(DecodeHintType.POSSIBLE_FORMATS, formats);
const reader = new MultiFormatReader();
let fileBuffer = fs.readFileSync(filePath);
// const byteArray = new ByteArray(fileBuffer);
const byteArray = new Uint8Array(fileBuffer);
const luminanceSource = new RGBLuminanceSource(byteArray, 400, 400);
const binaryBitmap = new BinaryBitmap(new HybridBinarizer(luminanceSource));
try {
const result = reader.decode(binaryBitmap, hints);
return result;
} catch (error) {
console.log(error);
return null;
}
};
David Werth commented
whats the error when you run it in node?
Brian commented
Same issue here, I believe this library is just out-of-date. Unfortunate since there isn't many alternatives. :-(
David Werth commented
It is in maintenance mode. If I could find anybody to take over I'd be glad