2026-11-11 · Images read as the pages of one document

2026-11-11 · Images read as the pages of one document

Context

Archives are photographed page by page: a letter of four sheets is four JPEGs, a register a folder of hundreds. Kalamu read every image as a document of its own, so a letter came back as four results, and a table of contents could not follow an article over two photographs. The only way to read them as one was to make a PDF first, outside the app (#52). This is the first of the issue’s two increments; pairing existing transcriptions with their scans is the second.

The reference projects read a folder of images as separate files in plain sorted() order (page10 before page2) and never as one document, so there was nothing to port: the natural order and the document are Kalamu’s.

The design question was the cache. A result is keyed by the source’s fingerprint and the piece (CacheKey::compute(task, source_sha256, piece, …)), and a PDF’s page is PieceRef::Page { number }, its place in the file. A document of images keyed the same way, by a hash of its pages and their places, would read every page again when one page moved.

Decisions

Consequences

Architecture checkpoint

The change crossed five crates and the shell, as the issue expected, without a new internal dependency: core holds the type, the order, the notes and the cache identity; media reads the pages; engine makes and settles the document and keys its pages through core; export measures ALTO pages per file; projects asks core which files a document has. store needed no change beyond a test. The engine gained image as a test-only dependency, already in the workspace. core/src/ordered.rs stays under 500 lines with its tests in a file of their own; media/src/lib.rs was already past 500 (544 now) and keeps the page set in its own module; NewJob.svelte grows by 50 lines to 975, the order itself in PageOrder.svelte and the logic in pageOrder.ts. Resuming, caching, progress and provenance cover the new path: a job stopped mid-document resumes with the pages not yet read, a page moved hits the cache, progress counts pages as for a PDF, and provenance names every file.