@agnamo/ocrstudio
v0.1.0
Published
Headless OCR pipeline CLI: turn images, PDFs, DOCX and text files into text or spreadsheets. Extracted from the OCR STUDIO workbench.
Maintainers
Readme
@agnamo/ocrstudio
Headless OCR pipeline CLI extracted from the OCR STUDIO workbench. It turns images, PDFs, DOCX files and plain text into text or spreadsheets — no picker, no plasma loader, just the OCR function behind a stable command line.
The package ships on npm, but the pipeline itself is Python. The npm bin is a
thin launcher that finds a local Python 3.9+ interpreter and runs the
bundled ocrstudio module, exactly like @agnamo/ldxv and @agnamo/ludvig.
Install
npm install -g @agnamo/ocrstudioPython 3.9+ is required. The launcher probes py -3 / python / python3;
set OCRSTUDIO_PYTHON to force a specific interpreter.
OCR backends
At least one backend is needed to produce text:
| backend | provides | install |
|---|---|---|
| Tesseract CLI | image + scanned-PDF OCR | winget install UB-Mannheim.TesseractOCR · apt install tesseract-ocr · brew install tesseract |
| pytesseract | same, via Python | pip install pytesseract pillow |
| PyMuPDF | PDF text layer and page rasterising | pip install pymupdf |
| poppler | pdftoppm / pdftotext / pdfinfo fallbacks | apt install poppler-utils |
| openpyxl | .xlsx output | pip install openpyxl |
engine=auto reads the PDF text layer first and only rasterises + OCRs pages
whose text layer is empty or shorter than 40 characters.
ocrstudio --list-enginesUsage
ocrstudio . # OCR everything under cwd
ocrstudio "C:\path\to\folder" --format csv
ocrstudio scan.pdf payslips/ --engine auto --out ./out --yes
ocrstudio . --format json --json > result.json # machine-readable stdout| flag | meaning |
|---|---|
| paths... | files or folders (default: current directory) |
| --format, -f | dir text markdown csv tsv json xlsx |
| --engine, -e | auto (default) · tesseract · text-layer |
| --out, -o | output destination |
| --dpi | raster DPI (default 300) |
| --lang | tesseract language pack, e.g. eng or eng+deu |
| --jobs | parallel workers (default: cores − 1, capped at 6) |
| --yes, -y | accepted for compatibility; this CLI is always headless |
| --json | print a machine-readable JSON result on stdout |
| --list-engines | what is installed |
| --version | print the version |
Output contract
stdout is data and stderr is presentation.
- By default stdout is the single primary output path.
- With
--json, stdout is a JSON object:{ ok, output, destination, engine, dpi, lang, stats }. - All banners, progress lines and the human summary go to stderr.
Exit codes: 0 success · 1 runtime/write error or pages with errors ·
2 bad arguments or no OCR-able files.
The destination defaults to ocr-out-<YYYYmmdd-HHMMSS>/ next to the input.
A run writes a .ocrstudio marker so a retry clears its own previous pages
instead of mixing them with fresh ones; a folder holding unrelated files is
never cleared.
dir— one.txtper page plus_manifest.jsontext/markdown— single document,--- page N ---boundaries on multi-page sourcescsv/tsv— one row per page; cells starting with= + - @are prefixed with'json— structured pages with textxlsx— one row per page; pages longer than 30 000 characters continue onpartrows
Development
npm run check # node --check + python py_compile
npm test # node --test smoke tests
npm run pack:check # npm pack --dry-runThe Python package layout:
ocrstudio/engine.py— the extracted OCR function (page counting, tesseract/poppler/PyMuPDF drivers,process_unit)ocrstudio/output.py— output format writers and destination safetyocrstudio/cli.py— argument parsing and the headless runnerocrstudio/util.py— file discovery and small helpers
