Skip to main content

scanmate-ink

The pixel and geometry kernel behind ScanMate: raster codec, ink separation, warps, homographies, FFT and the pipeline contracts.

A parallel port of @scanmate/ink, not a replacement for it. The TypeScript remains the reference, and the only useful definition of "correct" for this package is that it produces the same numbers — bit for bit — as the TypeScript it parallels.

pip install scanmate-ink
from scanmate_ink import decode_image, ink_map, to_grayscale

page = decode_image("form.png")
ink = ink_map(to_grayscale(page))

HEIF — what a phone camera emits — needs a separate decoder wheel, so it is opt-in rather than a hard dependency of the numeric core:

pip install 'scanmate-ink[heif]'

What "parallel port" means here

Every numeric result is held to the TypeScript's own output by goldens generated from the real @scanmate/ink build. The comparison is ==, not "close": a port that is right to six places and wrong in the last bit produces a different sample, and every downstream result diverges from there.

Three things genuinely differ between the two runtimes, none of them anybody's bug, and each is measured and pinned separately rather than folded into one tolerance:

Disagreement
sin(±π/4) 1 ULP, MSVC's libm vs glibc's
Math.hypot vs math.hypot 16% of inputs — hence scanmate_ink.hypot
Math.round vs round every half-way case — hence js_round

Two exports of the TypeScript are deliberately absent: resampleRaster and blurRaster go through libvips, and Pillow's LANCZOS disagrees with libvips' lanczos3 on 78.8% of pixels while libvips' blur is an integer approximation of a Gaussian. A Python "equivalent" would be a different operation wearing the same name. resize_gray and box_blur_raster are ScanMate's own resampler and blur, are ported, and are bit-exact.

Requirements

Python 3.11 or newer. Fully typed (PEP 561), mypy --strict clean.

Release files for scanmate-ink 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scanmate-ink 0.0.1
File Size Uploaded
scanmate_ink-0.0.1.tar.gz 111.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scanmate-ink 0.0.1
File Interpreter ABI Platform
scanmate_ink-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 196.3 kB

Release files / scanmate_ink-0.0.1.tar.gz

Download URL scanmate_ink-0.0.1.tar.gz
Size 111.9 kB
Tags Source
SHA-256 checksum
How to use checksums
71bf2aff62220d6d1e78e2bdaaab2f9863c4fc00d990d8051dcc1c8bcfdb9a7f
BLAKE2b-256 checksum
How to use checksums
39f974019e2d562c8b85f117c81956e819e131b901ab0c71700dc81ba5d4e703
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / scanmate_ink-0.0.1-py3-none-any.whl

Download URL scanmate_ink-0.0.1-py3-none-any.whl
Size 84.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c9bad84b8850bce5f7359a9e31e792cbda5e7017ecfc1225e515989fe6fa3ab
BLAKE2b-256 checksum
How to use checksums
458c5e2672d45cbcf98cc12ac5509582309e87b79f38a6f2ba668f2f69ece28e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.24.2

2 release files

0.24.1

2 release files

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page