Know what is on a scanned page before you run OCR on it.
pagetriage measures tilt, blur, bleed-through and folds, tells a real text layer from a scan, and flags legacy Hindi fonts. It uses no model, so the same page gives the same answer every time. Try it below: everything runs in this tab. Nothing is uploaded; the only network requests are for this page's own files.
Sprint 5 (18 Nov 2026): Working: the same page analysis as before, now with the PDF structure call that the dockit demo uses documented (analyse_pdf_structure: which pages of a PDF hold a readable text layer), with its WebAssembly size and its timings measured in Chrome on a 48 GB Apple M5 Pro (not measured on 8 GB). Not yet: OCR, 8 GB figures (not measured on 8 GB), a signed release, a tag, a published package, Linux and Windows wheels (Sprint 6).
The original scan
Drop a PDF here
It stays in this tab. Files up to 256 MB.
Readout
What it reads today
| Question | How | Status | Details |
|---|---|---|---|
| Loading the table. | |||
The same page gives the same answer, byte for byte
One Rust core builds for the command line, for Python and for the browser. Every golden page in the repository runs through all three, on Linux, macOS and Windows, in CI, and the report fingerprints have to match before anything merges.
That is harder than it sounds. The platform maths library (exp, sin, cos) differs in the last digit between glibc, Apple's libm and WebAssembly, and unordered maps iterate in a different order on every run. Both are banned from the core; sums over pixels happen in a fixed order, and the report writer rounds and sorts before anything is printed.
The proof is in the demo above: the fingerprint this tab computes is compared with the one the native build produced for the same sample. The guarantee covers the analyser given identical pixels. Image decoders are outside it, which is why a JPEG opened by two different decoders can differ.
How well it works
Every number comes from this repository's own benchmark scripts. Where the evidence is weaker than the number looks, the last column says so.
| Check | Result | How far to trust it |
|---|---|---|
| Text layer, 300 synthetic PDF pages | 300 of 300 right | Weak: we wrote the corpus. Two settings were tuned on half of it; the other half scored 159 of 159. |
| Legacy Hindi fonts, same corpus | 17 of 17 found, none among the other 283 pages | Weak: the font list was written from memory and no real deed was tested. |
| Tilt, 984 rotations of 82 DIBCO pages | median error 0.05 degrees | Solid for the median; the tail is poor (90th percentile 0.75 degrees, worst 26.5 on papyri). |
| Howe black-and-white method, DIBCO 2011 (held out) | F-measure 89.6, the paper reports 91.9 | Short of the target we set; three dark-background pages cause the gap. |
| Howe, DIBCO 2009 and 2010 (tuned here) | F-measure 94.0, the paper reports 93.8 | Settings were chosen on these pages. |
| Speed | quality pass about 63 ms on one synthetic A4 page at 150 dpi | Measured on an Apple-silicon laptop, native, one page type; full-page time and throughput are not measured yet (cut to Sprint 6); the 8 GB Windows laptop is not measured. |
About this demo
The page is built from main by .github/workflows/pages.yml on every push, and only after the WebAssembly build has reproduced every native fingerprint in samples.json. loading · package build loading.
Browser requirements
Checked by this page when it loaded. It needs WebAssembly and module workers: Chrome or Edge 80, Safari 15, Firefox 114, or later.
- checkingWebAssemblyruns the analyser, the same Rust core as the command-line tool.
- checkingModule workersrun the analyser off the main thread, so the page stays responsive.
- checkingCanvas 2Ddecodes the page image to pixels and draws the black-and-white masks.
- checkingFile APIreads a chosen or dropped file in the tab; nothing is uploaded.
No storage is used beyond the browser's HTTP cache, and no third-party script, font or analytics is loaded.
What this demo does not do yet
- No OCR, and no text extraction. This library does not read text; it tells you what is on the page before you spend OCR on it. For PDFs it says which pages hold a text layer (the call the dockit demo uses is documented in docs/wasm-api.md); reading that text is dockit's step, and scanned pages are not read at all yet.
- No model. Every number comes from hand-written features and fixed thresholds, by project rule, so no confidence is calibrated on real pages; calibration needs labelled real pages and is not part of Sprint 5.
- No tiling over 36 megapixels. Images over 36 megapixels are refused in the tab, and the core has no tiling for pages that large; no sprint is scheduled for it. The command-line tool has no such cap.
- No 8 GB figures. Speed and memory on the 8 GB Windows laptop without a GPU are not measured on 8 GB (release row 2, the owner's step). The only in-browser timings, for the PDF structure call, were measured on a 48 GB Apple M5 Pro in Chrome (docs/benchmarks/wasm-structure.csv); the full-page and large-PDF bench scripts are cut to Sprint 6. The Windows determinism job ran on a hosted GitHub runner, which is not the target laptop.
- No published package, and no tag. Nothing is on crates.io, PyPI or npm and the names are not reserved. A wheel and an npm tarball install from locally built files, proven on macOS arm64 only; no version is tagged. The blockers are listed in docs/release.md.
- No Linux or Windows wheel. Only the macOS arm64 wheel has been built; wheels for the other platforms and an sdist are cut to Sprint 6 and are not built.
- No signed release. A release manifest can be written and checked, but no real signing key exists, so nothing is signed (release row 4, the owner's step).
- No upload, ever. Images and PDFs never leave the tab, so there is no server-side analysis, no sharing link and no saved history.
- No service worker: offline after the first load is best effort (Chrome's HTTP cache), not guaranteed.
Run it yourself
It is not yet on crates.io, PyPI or npm, so you build from source (the README's Install section also shows how to build and install a wheel and an npm tarball locally). rust-toolchain.toml selects Rust 1.98.
Command line
git clone https://github.com/AirplaneMode-Labs/pagetriage
cd pagetriage
cargo build --release -p pagetriage-cli
target/release/pagetriage analyse page.png
target/release/pagetriage structure file.pdf
Add --pretty to indent the JSON; the compact default is the byte-reproducible form.
Python
python3 -m venv .venv
source .venv/bin/activate
pip install maturin pillow
maturin develop --release \
-m crates/pagetriage-py/Cargo.toml
import json, pagetriage_py as pt
from PIL import Image
im = Image.open("page.png").convert("L")
gray, (width, height) = im.tobytes(), im.size
report = json.loads(pt.analyse_page(gray, width, height, 150))
report["quality"]["skew_deg"]
Browser
scripts/install-wasm-tools.sh
PAGETRIAGE_WASM_FEATURES=pdf \
scripts/build-wasm.sh
import init, { analyse_page, rgb_to_gray }
from "./pkg/pagetriage.js";
await init();
const gray = rgb_to_gray(rgbBytes);
const report = JSON.parse(analyse_page(
gray, undefined, width, height, 150,
undefined, "{}"));
Built on
- N. R. Howe, "Document binarization with automatic parameter tuning", IJDAR 2013. doi:10.1007/s10032-012-0192-x; author's manuscript.
- N. R. Howe, "A Laplacian energy for document binarization", ICDAR 2011.
- N. Otsu, "A threshold selection method from gray-level histograms", 1979.
- J. Sauvola and M. Pietikainen, "Adaptive document image binarization", 2000.
- J. Canny, "A computational approach to edge detection", 1986.
- Y. Boykov and V. Kolmogorov, "An experimental comparison of min-cut/max-flow algorithms for energy minimization in vision", 2004.
- B. B. Chaudhuri and U. Pal, "Skew angle detection of digitized Indian script documents", 1997.
- ISO 32000, the PDF specification.
The full list, with what each paper is used for, is in docs/REFERENCES.md. A few entries there are marked unverified: a citation or formula recalled from memory and not yet checked against the paper.