A top-bar tool (#/ocr) to extract text from an image or PDF, running ENTIRELY in the browser — the document is never uploaded. - Engine selector (per OCR.md): Tesseract.js (Apache-2.0 WASM, recommended — 100+ languages via on-demand tessdata) or ocrs (experimental). PDFs reuse the PDF.js loader: each page → canvas → OCR. Result box with Copy / Download .txt and a progress indicator; drag-drop or browse for the file. - ocrs has no stable in-browser build yet (verified), so it's a best-effort seam (window.OCRS.recognize) that degrades with an honest message pointing at Tesseract.js — faithful to OCR.md rather than faking it. - CSP: allow https://cdn.jsdelivr.net (script/worker/connect) for tesseract.js and add 'wasm-unsafe-eval' to script-src (needed to compile the WASM engine; narrower than 'unsafe-eval'). Documents stay on the box — only the engine and language model are fetched. - New `scan` icon, full EN/PL i18n, .ocr-drop styling. - Docs: README feature row, FUNCTIONAL section, CLAUDE invariant, CREDITS (tesseract.js/tessdata Apache-2.0, ocrs MIT/Apache-2.0). Commit OCR.md (the research/merit) and its linked doc-to-docx research note. Verified end-to-end in the preview: tesseract.js loaded from jsDelivr under the new CSP and recognized rendered canvas text exactly ("Galena OCR 12345"). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
12 KiB
OCR options for Galena — research & recommendation
Scope: on-demand, interactive OCR — a user opens a scanned image/PDF and extracts its text to copy/paste or download (not bulk indexing; layout/table extraction only secondary). Compared across browser (WASM) / server / cloud, with exact licenses + pricing, mapped to Galena's constraints: Apache-2.0 core ships only permissive deps, plugins are frontend-only (the backend never executes plugin code), it's self-hosted and privacy-sensitive, and it already isolates copyleft as plugins (the GPL DjVu viewer) while keeping permissive features in core (the 0BSD RTF editor).
Researched June 2026 via a multi-source, adversarially-verified sweep: 25 sources fetched → 113 claims extracted → 25 verified (24 confirmed, 1 refuted). License facts are high-confidence (checked against primary LICENSE files); accuracy tiers are directional, not measured on Galena's own document mix. Cloud pricing and model-weight licenses are time-sensitive — re-verify at adoption.
TL;DR
- Unlike
.doc(seedocs/doc-to-docx-conversion-research.md), OCR has a clean permissive, frontend-only, on-box option. This is an RTF-style win, not a DjVu-style compromise. - Primary recommendation:
tesseract.js— genuinely Apache-2.0, runs OCR fully in-browser (WASM port of Tesseract's LSTM engine), documents never leave the box, 100+ languages via Apache-2.0 tessdata. It can live in core (like RTF) or a permissive plugin. - The trade-off is accuracy tier. tesseract.js is good on clean printed text but measurably weaker than PaddleOCR/docTR/cloud on noisy scans, dense layout, and handwriting.
- Higher accuracy, still on-box → operator-installed server sidecar (PaddleOCR/docTR/EasyOCR, Apache-2.0 but heavy Python deps). Highest accuracy → cloud, strictly operator opt-in (sending documents off a self-hosted box is a privacy conflict; never a default).
- Two licensing landmines: Surya (code Apache-2.0 but model weights are restricted Open-Rail-M with a $5M threshold + no-compete) and OCRmyPDF (MPL-2.0 + AGPL Ghostscript dep). Both are isolated-sidecar-only, not permissive-core/plugin.
Recommendation matrix
| Approach | Runtime | Accuracy | License + cost | Privacy | Galena slot |
|---|---|---|---|---|---|
| tesseract.js ⭐ | Browser/WASM | Mid (good clean print; weak noise/handwriting) | Apache-2.0 + Apache-2.0 tessdata, free | On-box ✅ | (a) permissive frontend plugin — or core (RTF model) |
| ocrs | Browser/WASM | Low–Mid (alpha, Latin-only) | MIT OR Apache-2.0, free | On-box ✅ | (a) secondary / experimental fallback |
| transformers.js + OCR model | Browser/WASM | Varies | Apache-2.0 lib; model weights vary (TrOCR not supported) | On-box ✅ | (a) only with a permissive in-browser model — not turnkey |
| PaddleOCR / docTR / EasyOCR / RapidOCR | Server (Python) | High | Apache-2.0 code (heavy PyTorch/Paddle; audit weights + sub-deps) | On-box ✅ | (c) operator server / sidecar — not a frontend plugin |
| OCRmyPDF | Server | Mid–High | MPL-2.0 + AGPL Ghostscript dep | On-box ✅ | (b) isolated sidecar (copyleft) |
| Surya | Server | High | ⚠️ code Apache-2.0, weights restricted (Open-Rail-M, $5M + no-compete) | On-box ✅ | (b)/(e) isolated, operator accepts weight terms; not permissive-eligible |
| Google Vision / AWS Textract / Azure / ABBYY / Mathpix | Cloud | Highest (+ handwriting) | Commercial, per page (Google $1.50/1k after 1k free) | Leaves the box ❌ | (d) operator opt-in only — never default |
(a) Browser / WASM — the permissive frontend-only tier
- tesseract.js — primary recommendation. Verified Apache-2.0 (repo,
LICENSE.md, npm). It "works by wrapping a WebAssembly port of Tesseract" and runs OCR client-side with no backend calls (a cited privacy feature) usingoem=1— the same LSTM neural engine as Tesseract 4/5.- Language data: the tessdata files are themselves Apache-2.0 (
tessdata_fast/tessdata_best_int), but are downloaded on demand per language (a few MB each, not bundled), so they carry an Apache NOTICE/attribution obligation and a first-use download cost. - Fully permissive dependency chain (zero copyleft) → eligible for core or a permissive plugin, your choice.
- Accuracy: good on clean printed text; weaker on noisy scans, dense multi-column layout, and handwriting than modern deep-learning engines and cloud APIs.
- PDF synergy: Galena already lazy-loads PDF.js for the PDF preview — render a page to a
<canvas>, hand the canvas to tesseract.js. Images go in directly.
- Language data: the tessdata files are themselves Apache-2.0 (
- ocrs (Rust→WASM) — the only other genuinely permissive in-browser engine, dual MIT OR Apache-2.0, with a real (alpha) browser/Node WASM build. Early preview, Latin-alphabet only, and self-admittedly below commercial accuracy → secondary/experimental fallback, not primary. (Separately-distributed ONNX weights may carry their own terms.)
- transformers.js — clean Apache-2.0, runs models client-side via ONNX Runtime Web (WASM on CPU; WebGPU opt-in). But the TrOCR-in-browser assumption is FALSE (refuted 0-3 — TrOCR isn't in its supported models). Document-vision models like Donut/DiT/Florence-2 are supported, but each checkpoint's weights carry their own license that must be audited before shipping. Not turnkey for OCR.
(b)/(c) Server-side — higher accuracy, on-box, but not a frontend plugin
The accuracy-leading permissive engines — Tesseract (Apache-2.0, the engine tesseract.js
wraps), EasyOCR (Apache-2.0), PaddleOCR (Apache-2.0), docTR/Mindee (Apache-2.0), and
RapidOCR (Apache-2.0, ONNX-converted PaddleOCR models) — are clean permissive code, but the
deep-learning ones run server-side in Python with heavy PyTorch/Paddle runtimes. They fit a Galena
operator server / sidecar (the same two-tier pattern OPTIONS.md proposes for Collabora), not a
frontend-only plugin. Audit per-component: EasyOCR/docTR pull PyTorch; PaddleOCR lists an AGPL
PyMuPDF; every engine ships separate model weights with independent licenses.
Note: RapidOCR's web offering (
RapidOCRWeb) is a Flask server (browser is only a UI client); a true browser-native WASM path for these models is third-party, not on the main repos.
The two licensing landmines (verified)
- Surya — the code
LICENSEis standard Apache-2.0 (recently changed from GPL-3.0), but a separateMODEL_LICENSEis the AI Pubs Open-Rail-M (Modified): free only for research/personal use and orgs under a $5,000,000 revenue/funding threshold, with a no-competing-products clause; broader commercial use needs a paid license. The permissive code is useless without the restricted weights → not permissive-core/plugin eligible; isolated, operator-accepted server context only. (History of license churn — re-verify.) - OCRmyPDF (the standard "make a scanned PDF searchable" tool) — MPL-2.0 (weak/file-level copyleft) plus a runtime dependency on AGPL Ghostscript → isolated sidecar territory, never permissive core or a permissive plugin. (Pluggable engine: Tesseract default; EasyOCR/PaddleOCR plugins exist.)
(d) Cloud — highest accuracy, but it leaves the box
Cloud APIs (Google Cloud Vision Document Text Detection, AWS Textract, Azure AI Document Intelligence, ABBYY, Mathpix for math) deliver top-tier accuracy incl. handwriting, but require transmitting the document off the self-hosted box — a direct conflict with Galena's privacy posture. Operator opt-in only, never a default.
- Google Cloud Vision pricing (verified): first 1,000 units/month free (metered per feature), then $1.50 / 1,000 units (1,001–5,000,000), then $0.60 / 1,000 above 5M. Billed per image / per page — each PDF page is a separate billable image, and each feature applied is a billable unit.
- AWS Textract, Azure Document Intelligence, ABBYY, Mathpix, Aspose.OCR pricing was not verified here — check directly before any cost decision.
What this means for Galena
| Need | Pick | Galena placement |
|---|---|---|
| On-box, permissive, default | tesseract.js | Core feature or permissive plugin (RTF model) |
| Higher accuracy, still on-box | PaddleOCR / docTR | Operator-installed server sidecar |
| Highest accuracy | Cloud API | Operator opt-in only (privacy) |
The clean play mirrors the RTF story: ship tesseract.js as an on-box "Extract text" action for images and PDFs (reusing PDF.js for page rendering), permissive and private by default; offer a server sidecar (PaddleOCR/docTR) and/or cloud as operator-opt-in upgrades for accuracy.
Caveats (honesty)
- Accuracy tiers are directional — from maintainers' self-assessments (ocrs and Surya disclose theirs) and general benchmarks, not measured on Galena's actual document profile.
- License verdicts cover engine CODE only. Every deep-learning option ships separate model weights and pulls runtime deps (PyTorch, Paddle, AGPL Ghostscript, AGPL PyMuPDF) with independent licenses to audit per-component.
- Only Google Vision cloud pricing was verified; AWS / Azure / ABBYY / Mathpix / Aspose were not.
- Surya has churned licenses ($2M→$5M threshold; GPL→Apache code) — re-verify both code and weights at adoption.
- RapidOCR / transformers.js have permissive libraries but no substantiated turnkey browser-native OCR path on their main repos — a frontend deployment needs extra integration and third-party ports.
Open questions
- tesseract.js's measured accuracy on Galena's real document mix (scanned vs born-digital, noisy faxes, CJK, handwriting) vs a server PaddleOCR/docTR sidecar — is the gap big enough to justify an opt-in server engine for privacy-sensitive cases?
- Exact current per-page pricing + data-retention terms for AWS Textract, Azure Document Intelligence/Read, ABBYY, Mathpix, Aspose.OCR.
- For a transformers.js in-browser plugin, which specific OCR model checkpoint is both browser-supported AND permissively-weighted (given TrOCR is unsupported and weights vary)?
- Real-world model/asset download cost and cold-start latency on typical hardware (tessdata a few MB/language on demand vs ONNX detection+recognition bundles for ocrs/transformers.js) — impact on the interactive on-demand UX.
Sources
- tesseract.js — https://github.com/naptha/tesseract.js · license https://github.com/naptha/tesseract.js/blob/master/LICENSE.md
- tessdata_fast (Apache-2.0 language data) — https://github.com/tesseract-ocr/tessdata_fast
- ocrs (Rust→WASM) — https://github.com/robertknight/ocrs
- transformers.js — https://github.com/huggingface/transformers.js/
- Tesseract — https://github.com/tesseract-ocr/tesseract
- EasyOCR — https://github.com/JaidedAI/EasyOCR/blob/master/LICENSE
- PaddleOCR — https://github.com/PaddlePaddle/PaddleOCR/blob/main/LICENSE
- docTR — https://github.com/mindee/doctr
- RapidOCR — https://github.com/RapidAI/RapidOCR
- Surya code license — https://github.com/datalab-to/surya/blob/master/LICENSE · model license — https://github.com/datalab-to/surya/blob/master/MODEL_LICENSE
- OCRmyPDF — https://github.com/ocrmypdf/OCRmyPDF
- Google Cloud Vision pricing — https://cloud.google.com/vision/pricing
- AWS Textract pricing — https://aws.amazon.com/textract/pricing/
- Azure AI Document Intelligence pricing — https://azure.microsoft.com/en-us/pricing/details/document-intelligence/
- Mathpix pricing — https://mathpix.com/blog/image-api-price-reduction