scanlayer
Scanned image or photographed document → searchable PDF, or raw OCR text/JSON/TSV/hOCR.
Turn a scanned image or photographed document into a searchable PDF, or export the raw OCR result as plain text, JSON, TSV, or hOCR. Use it as a command-line tool or as a Python library; both are the same engine underneath.
What it does
A scanned invoice, a phone photo of a letter, a stack of photographed pages: scanlayer runs it through Tesseract OCR and gives you back either:
- a searchable PDF: the original page image, with an invisible, precisely positioned text layer over it, so you can select and search text exactly where it visually appears, or
- the raw OCR result as
txt,json,tsv, orhocr: text, per-word confidence, and bounding boxes, no PDF built at all.
Along the way it automatically straightens rotated/skewed pages, corrects uneven lighting, denoises and sharpens for OCR accuracy without touching what you actually see in the output, reconstructs correct reading order on genuine multi-column pages, and races several OCR configurations against each other to pick the most confident result.
| Two interfaces, one engine | scanlayer CLI and import scanlayer call the exact same pipeline |
| Five output formats | Searchable pdf, or raw txt / json / tsv / hocr |
| Real column detection | Two-column articles/letters read in correct order, not interleaved |
| Batch, merge, native PDF input | Convert a folder in one call, merge pages into one PDF, or --dry-run a batch before spending time on OCR |
| One configuration surface | configure(), a JSON/YAML profile, or CLI flags, documented precedence |
| Debug overlay | --debug-image draws every word, color-coded by confidence |
See the feature catalog for the complete list, and Roadmap & Limitations for what's deliberately out of scope or not built yet.
Requirements
- Python 3.9+
- Tesseract OCR (a separate, system-level install, see below)
- poppler only if you feed scanlayer a native
.pdffile directly
# Debian / Ubuntu
sudo apt install tesseract-ocr poppler-utils
# macOS (Homebrew)
brew install tesseract poppler
# Windows: Tesseract -> https://github.com/tesseract-ocr/tesseract/wiki
# poppler -> download a release, add its bin/ to PATH
Full detail, including how scanlayer locates the Tesseract binary automatically and how to bundle your own, is in Installation and Bundling Tesseract.
Install
pip install scanlayer
This installs the scanlayer console command and makes import scanlayer
available anywhere on the machine.
Working on scanlayer itself, or want to run it straight from a checkout with no install at all?
git clone https://github.com/Hyacinthe-primus/scanlayer.git
cd scanlayer # the repo root, which contains requirements.txt
pip install -r requirements.txt
python -m scanlayer invoice.jpg -o invoice.pdf # works with no install at all
See CONTRIBUTING.md for the full contributor setup (editable install and running the test suite).
Quick start
As a CLI:
scanlayer invoice.jpg -o invoice.pdf --lang fra+eng --dpi 300
As a library:
import scanlayer
result = scanlayer.convert("invoice.jpg", "invoice.pdf", lang="fra+eng", dpi=300)
print(f"{result.words_count} words, {result.mean_confidence:.1f}% confidence")
Every CLI flag and library keyword argument in this project are named to
match each other (--lang ↔ lang=, --dpi ↔ dpi=, and so on), see
Examples for every
feature shown both ways, side by side, and
CLI Reference /
Library API for
the complete details of each.
A few more common cases:
# Batch-convert a folder
scanlayer *.jpg -o ./converted/
# Merge several photographed pages into one searchable PDF
scanlayer page1.jpg page2.jpg page3.jpg -o report.pdf --merge
# Export raw OCR text/JSON instead of a PDF
scanlayer invoice.jpg -o invoice.json --format json
# See what OCR actually detected, color-coded by confidence
scanlayer invoice.jpg --debug-image
# Validate a batch before spending time on OCR: files exist,
# Tesseract reachable, output paths writable
scanlayer *.jpg -o ./converted/ --dry-run
import scanlayer
# Batch
result = scanlayer.convert_batch(["*.jpg"], "./converted/")
# Merge
scanlayer.convert_merge(["page1.jpg", "page2.jpg", "page3.jpg"], "report.pdf")
# Raw export
scanlayer.convert("invoice.jpg", "invoice.json", output_format="json")
Documentation
| Installation | Tesseract, poppler, and the two ways to install scanlayer itself |
| Examples | Every feature, CLI and library side by side |
| CLI Reference | Every flag and exit code |
| Library API | convert(), convert_batch(), convert_merge(), exceptions, and the full low-level pipeline API |
| Feature Catalog | Everything scanlayer does, by pipeline stage |
| Configuration | configure(), config files, precedence, every tunable |
| Output Formats | The pdf/txt/json/tsv/hocr schemas |
| Multi-Page & Merge | Batching, merging, native PDF input |
| Debug Visualization | Reading the --debug-image confidence overlay |
| Bundling Tesseract | Shipping your own Tesseract binary |
| Troubleshooting | Common errors and fixes |
| Roadmap & Limitations | What's missing and what's deliberately out of scope |
The site is published from the gh-pages branch at
https://Hyacinthe-primus.github.io/scanlayer/. To browse it locally, open
index.html in a gh-pages worktree (e.g. git worktree add <path> gh-pages);
it has no build step or server-side dependency.
Repository layout
.
├── .github/ # FUNDING.yml
├── scanlayer/ # library source
│ ├── __init__.py
│ ├── __main__.py # enables `python -m scanlayer`
│ ├── main.py # public API: convert()/convert_batch()/convert_merge()
│ ├── config.py
│ ├── cli/ # argparse CLI: parser.py, run.py, dry_run.py
│ ├── fonts/ # bundled DejaVu Sans for the PDF text layer
│ ├── preprocessing/
│ ├── ocr/
│ ├── layout/
│ ├── pdf/
│ └── utils/
├── tests/ # pytest suite
├── pyproject.toml
├── requirements.txt
├── README.md
├── CONTRIBUTING.md
├── SECURITY.md
└── LICENSE.md
Contributing
Bug reports, fixes, and feature discussions are welcome: see
CONTRIBUTING.md for how to set up a development
environment and what to include in a pull request. There is a tests/
directory (now including utils/validators.py and the --dry-run flag, with
cross-platform coverage for Tesseract discovery on Windows/macOS/Linux) and it runs with pytest, but no CI yet; see Roadmap & Limitations and the Adding tests section of the contributing guide for where coverage is thinnest.
License
MIT.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scanlayer-1.0.2.tar.gz.
File metadata
- Download URL: scanlayer-1.0.2.tar.gz
- Upload date:
- Size: 438.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a022d824ad3539bab101ab1f47d1dd49908fd3add5d2469228b0dde95681dbc
|
|
| MD5 |
4faa4ec8710e9a4f61831ba8f86ac2f6
|
|
| BLAKE2b-256 |
7721c2203eb948a63e3e0dc707949340b5a8a3364e8c00bdb95b99e28d654ad9
|
Provenance
The following attestation bundles were made for scanlayer-1.0.2.tar.gz:
Publisher:
pypi-publish.yml on Hyacinthe-primus/scanlayer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scanlayer-1.0.2.tar.gz -
Subject digest:
6a022d824ad3539bab101ab1f47d1dd49908fd3add5d2469228b0dde95681dbc - Sigstore transparency entry: 2645902308
- Sigstore integration time:
-
Permalink:
Hyacinthe-primus/scanlayer@152bda9bcda1b9971f085c71ed2aaf91948cafc8 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Hyacinthe-primus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@152bda9bcda1b9971f085c71ed2aaf91948cafc8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scanlayer-1.0.2-py3-none-any.whl.
File metadata
- Download URL: scanlayer-1.0.2-py3-none-any.whl
- Upload date:
- Size: 432.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fbe97552d69e613eb4d27f0af4d646c24d992c323ccc94c40af925abcdfcba5
|
|
| MD5 |
1d8f4c5da7cc746e83f0f6b053036497
|
|
| BLAKE2b-256 |
abbe8562c6a9492c898671d6005ea16afa53eb6f35d3e6e4bac3832d459c9e2a
|
Provenance
The following attestation bundles were made for scanlayer-1.0.2-py3-none-any.whl:
Publisher:
pypi-publish.yml on Hyacinthe-primus/scanlayer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scanlayer-1.0.2-py3-none-any.whl -
Subject digest:
5fbe97552d69e613eb4d27f0af4d646c24d992c323ccc94c40af925abcdfcba5 - Sigstore transparency entry: 2645902431
- Sigstore integration time:
-
Permalink:
Hyacinthe-primus/scanlayer@152bda9bcda1b9971f085c71ed2aaf91948cafc8 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Hyacinthe-primus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@152bda9bcda1b9971f085c71ed2aaf91948cafc8 -
Trigger Event:
push
-
Statement type: