@molecule/api-ocr-tesseract
Provider bond · ocr · API (Node) · v1.1.1 · Apache-2.0
Self-hosted Tesseract OCR provider for molecule.dev — text extraction from images in your own process, no vendor account, no per-call cost
npm install @molecule/api-ocr-tesseractnpm · Source on GitHub · Implements @molecule/api-ocr
How it works
@molecule/api-ocr-tesseract is a provider bond on the API (Node) side: it implements the ocr core interface (@molecule/api-ocr) with a concrete vendor or library behind it.
Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.
Works with: @molecule/api-ocr
Reference
Self-hosted Tesseract OCR provider for molecule.dev — text extraction from images in your own process, no vendor account, no per-call cost
Type
provider
Installation
npm install @molecule/api-ocr-tesseract @molecule/api-ocr tesseract.js
API
Interfaces
TesseractOcrConfig
Options for createProvider. Tesseract runs entirely in your process
(a WASM worker thread) — no API key, no egress except the first download of
a language's traineddata unless you point langPath at a local copy.
interface TesseractOcrConfig {
/** Default Tesseract language code(s), `+`-joined (e.g. `eng`, `eng+deu`). Default `eng`. */
language?: string
/**
* Where traineddata files are downloaded from. Defaults to the tessdata CDN
* the library ships with. Point it at your own mirror or a local directory
* (`file://…` or a path the worker can read) for offline installs.
*/
langPath?: string
/** Directory to cache downloaded traineddata in. Default: the OS temp dir. */
cachePath?: string
/**
* Whether to fetch `.traineddata.gz` (compressed). Default true; set false
* for a `langPath` that only serves uncompressed files.
*/
gzip?: boolean
}
Functions
createProvider(config)
Creates a self-hosted Tesseract OCR provider.
function createProvider(config?: TesseractOcrConfig): OcrProvider
config— Default language and traineddata source.
Returns: An OcrProvider backed by Tesseract in a worker thread.
Constants
provider
The provider implementation.
const provider: OcrProvider
Core Interface
Implements @molecule/api-ocr interface.
Bond Wiring
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/api-ocr'
import { provider } from '@molecule/api-ocr-tesseract'
export function setupOcrTesseract(): void {
setProvider(provider)
}
Injection Notes
Requirements
Peer dependencies:
@molecule/api-ocr>=1.0.0
Runtime Dependencies
@molecule/api-ocrtesseract.js