Skip to main content

Dead-simple offline OCR for developers. No cloud. No API keys.

Project description

ocrlocal

PyPI version Python versions License: MIT Offline

Dead-simple offline OCR for developers. Point it at an image. Get text. No cloud. No API keys.

ocrlocal wraps Tesseract via pytesseract + Pillow into a polished CLI with batching, JSON output, and a delightful doctor check.


Install

pip install ocrlocal

You also need the Tesseract binary on your system:

Platform Command
Debian / Ubuntu sudo apt update && sudo apt install -y tesseract-ocr
macOS brew install tesseract
Windows (Chocolatey) choco install tesseract
Windows (installer) UB Mannheim builds

Verify everything in one shot:

ocrlocal doctor

60-second demo

# Single image → stdout
ocrlocal receipt.png

# Language pass-through (Tesseract style)
ocrlocal scan.png --lang eng+fra

# Batch + JSON for scripts
ocrlocal photos/*.png --json

# Write .txt files into a folder
ocrlocal invoices/*.jpg --out ./text

Sample JSON:

[
  {
    "file": "receipt.png",
    "text": "TOTAL 12.50",
    "lang": "eng",
    "engine": "tesseract"
  }
]

ocrlocal doctor

A green/red health check for your local OCR stack:

ocrlocal doctor
═══════════════

  ✓  ocrlocal           v0.1.0
  ✓  tesseract binary   /usr/bin/tesseract — tesseract 5.3.0
  ✓  pytesseract        v0.3.13
  ✓  Pillow             v10.4.0

All checks passed. Ready for offline OCR.

If Tesseract is missing, doctor exits with code 2 and points you at apt / brew / choco / the Windows installer.


Features

Feature Details
Offline-only Never phones home. No network calls.
Single or batch Files and shell globs
--json Machine-friendly {file, text, lang, engine} list
--lang Full Tesseract lang strings (eng, eng+fra, …)
--out DIR Write mirrored .txt files
Exit codes 0 ok · 1 OCR/file errors · 2 missing Tesseract/config
-q / -V Quiet mode · version
doctor Binary + library diagnostics

vs calling pytesseract yourself

Raw pytesseract ocrlocal
CLI DIY Ready
Batch / globs DIY Built-in
JSON for scripts DIY --json
Missing-binary UX Cryptic Install hints + exit 2
Health check None ocrlocal doctor
Output files DIY --out DIR

Use the library if you are embedding OCR deep in an app. Use ocrlocal when you want a dependable terminal tool.


CLI reference

ocrlocal [OPTIONS] [IMAGES]...
ocrlocal doctor
Option Meaning
--lang / -l Tesseract languages (default: eng)
--json JSON array on stdout
--out DIR Write .txt files into DIR
-q / --quiet Errors only
-V / --version Print version

Exit codes

  • 0 — success
  • 1 — one or more OCR / file errors (partial batch still reports successes)
  • 2 — missing Tesseract or broken config

Troubleshooting

Symptom Fix
Tesseract OCR was not found Install the system binary (table above), then ocrlocal doctor
Wrong / empty text Try a sharper crop; set --lang to match the document
Not a supported image file Pass a real PNG/JPEG/TIFF/WebP — not a PDF or text file
Language data missing Install packs, e.g. tesseract-ocr-fra on Debian
Integration tests skipped Expected without Tesseract; mocked suite still covers behavior

Development

git clone https://github.com/AshSgDe29071999/ocrlocal.git
cd ocrlocal
pip install -e ".[dev]"
pytest

Integration tests that hit a real Tesseract binary are skipped automatically when tesseract is not on PATH.


License

MIT © AshSgDe29071999

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocrlocal-0.1.1.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ocrlocal-0.1.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file ocrlocal-0.1.1.tar.gz.

File metadata

  • Download URL: ocrlocal-0.1.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ocrlocal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 996235fc52f3763685303f8efcad4a6de60369056d8b986608d5044120aba2bd
MD5 91e92142192cd1d4831f0bb5a0b41c9c
BLAKE2b-256 0f28df693f11c12d14a290031f0cfa6ae31a7bbc11626fe0bdab6ada1014cb0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocrlocal-0.1.1.tar.gz:

Publisher: publish.yml on AshSgDe29071999/ocrlocal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ocrlocal-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ocrlocal-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ocrlocal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a688c0bc1c41012d2b13cc6881532f9e3d294a14fce54a88ae0f763469efe5cd
MD5 956405e5d4b528ad8f8d8a860cc95e83
BLAKE2b-256 313bf768e3cb4f5a8849138d1d533a38b9c157059b280d9b31fbf4ccd17140a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocrlocal-0.1.1-py3-none-any.whl:

Publisher: publish.yml on AshSgDe29071999/ocrlocal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page