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.24.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.24.1
File Size Uploaded
scanmate_ink-0.24.1.tar.gz 111.9 kB Details

Built distribution (wheel)

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

Total release size: 196.3 kB

Release files / scanmate_ink-0.24.1.tar.gz

Download URL scanmate_ink-0.24.1.tar.gz
Size 111.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4288441ba06110e7d2e9ec2932d17285bd2b7040dd0ec89abdee154f4d31f839
BLAKE2b-256 checksum
How to use checksums
6088acf8f62d9e874408c2d73fd8a023be0696ae104ffde8faf314d3cb9e4333
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.24.1-py3-none-any.whl

Download URL scanmate_ink-0.24.1-py3-none-any.whl
Size 84.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af70b6975f9882d95364293387a3aedb0ef7ec5493779a90cdeb570b15b81fa4
BLAKE2b-256 checksum
How to use checksums
abbb18aab9d53f4e52f842b416326c97ca8f36b3426abfb8d52869cf63e23c10
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

This release

0.24.1 This release

2 release files

0.0.1

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