Skip to content

deps: the ink layer of a scanned page, and a check that can see it - #14

Merged
tannevaled merged 1 commit into
mainfrom
deps-current
Aug 29, 2026
Merged

deps: the ink layer of a scanned page, and a check that can see it#14
tannevaled merged 1 commit into
mainfrom
deps-current

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The workbench was eight releases behind on the renderer, so none of the work on scanned pages reached anybody. render v0.19.0 brings the JBIG2 mask that gives a scanned page's ink its shape, the JPEG 2000 background under it, and optional content; gfx v0.15.0 brings the JBIG2 decoder those go through.

Handed a real scanned document, the browser check then said the page never arrived. It had.

It counted a pixel as dark when its three channels sum to under 240 — an average under 80, which is nearly black. That is the right question for telling a lit control from an unlit one, which is what it was written for. It is the wrong question for a page: scanned text scaled down to fit a window is grey.

the same page, same pixels count
dark by luminance 1805
by sum-of-channels < 240 9
the empty workbench's own strip and borders 453

The page covers that furniture, so a correctly drawn scanned document read as never having arrived.

The canvas now also counts ink — dark the way text is dark — and a document is seen to arrive when the canvas changed, more of it is drawn on than before, and there is more ink than the workbench's own furniture. Nearly black is still counted, and still used for what it is good at.

Checked both ways: the synthetic document still passes, and a 1556x2439 scanned medical page now opens and saves back out at 3 106 224 bytes.

Supersedes #13, which stopped at render v0.14.0.

The workbench was eight releases behind on the renderer, so none of the work
on scanned pages reached anybody. render v0.19.0 brings the JBIG2 mask that
gives a scanned page's ink its shape, the JPEG 2000 background under it, and
optional content; gfx v0.15.0 brings the JBIG2 decoder those go through.

Handed a real scanned document, the browser check then said the page never
arrived. It had.

It counted a pixel as dark when its three channels sum to under 240 — an
average under 80, which is nearly black. That is the right question for
telling a lit control from an unlit one, which is what it was written for. It
is the wrong question for a page: scanned text scaled down to fit a window is
GREY. The same page counts 1805 pixels dark by luminance and 9 by that sum,
and the empty workbench's own strip and borders have 453, which the page then
covers. So a correctly drawn scanned document read as never having arrived.

The canvas now also counts ink — dark the way text is dark — and a document is
seen to arrive when the canvas changed, more of it is drawn on than before, and
there is more ink than the workbench's own furniture. Nearly black is still
counted, and still used for what it is good at.

Checked both ways: the synthetic document still passes, and a 1556x2439 scanned
medical page now opens and saves back out at 3 106 224 bytes.

100% statement coverage, go vet and -race clean, the wasm build, and the
browser check.
@tannevaled
tannevaled merged commit 0f90154 into main Aug 29, 2026
2 checks passed
@tannevaled
tannevaled deleted the deps-current branch August 29, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant