Files
zemion 8f34d05b75
Verify / verify (push) Canceled after 0s
Release Scan Tools 0.2.0
2026-09-02 10:57:17 +02:00

38 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Architecture
The React workbench owns an in-memory ordered list of source `File` objects and
serializable page settings. No page content enters local storage. Each source is
decoded with `createImageBitmap`; its dimensions and byte size are checked before
it joins the workspace.
The renderer uses a disposable module worker and `OffscreenCanvas` when the
browser supports them. It downscales exceptionally large source rasters to a
24-megapixel working ceiling, then a projective map sends every destination
pixel through the four selected source corners and samples it bilinearly. A
bounded pixel pass applies brightness, contrast, perceptual grayscale and
optional Otsu/manual threshold. Canvas rotation handles quarter turns and the
final ±5 degree deskew. Worker jobs report stages, are terminated by abort and
cannot replace a newer preview. A bounded HTML-canvas fallback preserves the
same result where Worker/OffscreenCanvas are unavailable. Preview, OCR and
export call this renderer with different disclosed pixel budgets, so the preview
semantics match the downloaded result.
Deskew estimation downsamples to at most 420 pixels on the long edge, tests
half-degree candidates from 5 to +5, and scores the horizontal projection of
dark pixels. It declines to invent an angle when insufficient foreground exists.
PDF export dynamically loads jsPDF, renders pages sequentially, JPEG-encodes
each bounded page, and fits it into the selected physical page. OCR dynamically
loads Tesseract.js only after user confirmation. Its worker, three LSTM-only
runtime variants and English integer trained data are copied from pinned npm
packages to same-origin release assets. Tesseract's persistent model cache is
disabled, one in-memory worker is reused and can be terminated, and no fallback
CDN path is used.
OCR requests bounded block geometry, hOCR and TSV alongside plain text. Word
boxes are normalized to the corrected OCR raster for an inert SVG overlay and
are capped at 100,000 entries. hOCR is never injected into the application DOM;
it and TSV are download-only evidence. Any subsequent page adjustment clears
positioned OCR artifacts while retaining the user's editable plain text. PDFs
remain image-only rather than silently embedding a potentially misaligned layer.