-
Deno implements Here's what I've tried so far: #!/usr/bin/env -S deno run --ext=ts
import "npm:barcode-detector@^2";
const bytes = await new Response(Deno.stdin.readable).bytes();
const image = new Blob([bytes], { type: "image/png" });
const barcodeDetector = new BarcodeDetector({ formats: ["qr_code"] });
for (const { rawValue } of await barcodeDetector.detect(image)) {
console.log(rawValue);
} % cat ~/path/to/image.png | ~/path/to/detect-qr-code
error: Uncaught (in promise) ReferenceError: Failed to execute 'detect' on 'BarcodeDetector': document is not defined
at ar (~/Library/Caches/deno/npm/registry.npmjs.org/barcode-detector/2.2.11/dist/es/pure.js:1939:75)
at To.detect (~/Library/Caches/deno/npm/registry.npmjs.org/barcode-detector/2.2.11/dist/es/pure.js:2046:13)
at eventLoopTick (ext:core/01_core.js:175:7)
at async ~/path/to/detect-qr-code:8:28
info: document global is not available in Deno.
hint: Use a library like happy-dom, deno_dom, linkedom or JSDom
and setup the document global according to the library documentation. |
Beta Was this translation helpful? Give feedback.
Answered by
Sec-ant
Oct 22, 2024
Replies: 1 comment 2 replies
-
I'm afraid they're still not enough. As what are suggested in the error messages, DOM APIs are required. However, you have a better choice if you want to detect barcodes in deno: try zxing-wasm, which provides the core barcode detection ability of this package, exposes a lot more options and can run in more runtimes. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
mfulton26
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm afraid they're still not enough. As what are suggested in the error messages, DOM APIs are required.
However, you have a better choice if you want to detect barcodes in deno: try zxing-wasm, which provides the core barcode detection ability of this package, exposes a lot more options and can run in more runtimes.