Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import { extractBytes, initWasm, registerOcrBackend, TesseractWasmBackend } from "@kreuzberg/wasm";
async function extractWithProgressTracking() {
await initWasm();
const backend = new TesseractWasmBackend();
backend.setProgressCallback((progress: number) => {
const progressBar = document.getElementById("progress");
if (progressBar) {
progressBar.style.width = `${progress}%`;
progressBar.textContent = `${progress}%`;
}
});
await backend.initialize();
registerOcrBackend(backend);
const bytes = new Uint8Array(await fetch("document.png").then((r) => r.arrayBuffer()));
const result = await extractBytes(bytes, "image/png", {
ocr: {
backend: "tesseract-wasm",
language: "eng",
},
});
console.log("OCR complete");
console.log(result.content);
}
extractWithProgressTracking().catch(console.error);