Skip to content

Hand back the pictures a page draws, one by one - #30

Merged
tannevaled merged 2 commits into
mainfrom
page-images
Aug 29, 2026
Merged

Hand back the pictures a page draws, one by one#30
tannevaled merged 2 commits into
mainfrom
page-images

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

This package could draw a page and nothing else. A page is the wrong unit for two jobs.

Getting the pictures out of a document is one, and it is what pdfimages is for.

Finding out whether a codec is right is the other, and it is why this is here now. A page is a composition: one image decoded wrongly is averaged away by everything drawn over and around it, so a per-page difference of a few percent says nothing about which image was wrong. That is not hypothetical — v0.12.0 went out drawing scanned pages dark because what was measured was "ink appeared" rather than "the right ink", and a per-page number is what let it through.

Images returns each picture with:

  • the name the page draws it by;
  • the image filter it was stored in — which the pixels cannot tell you, and which a codec comparison must know;
  • whether it is a stencil, whose shape comes back without a colour, because the colour is not the image's to know.

Forms are followed, as pdfimages follows them: a picture reachable only through one is still a picture the page draws. A document may say a form holds itself, so the walk stops after eight levels.

The names are walked in order. A map hands its keys back differently every run, and a list of pictures that reorders itself is not a measurement — that has already cost this repository a day, in a filter table that answered five different ways in eight runs.

100% statement coverage, go vet and -race clean, nine cross-compile targets.

go-gfx/gfx v0.15.0 takes its JBIG2 decoder from a fork carrying one fix,
offered upstream as dkrisman/gobig2#2: the per-symbol pixel cap defaulted to 4
megapixels, below what real scanned documents contain, and a library could not
raise it because the limits are process-global variables.

Of 403 JBIG2 streams taken from the /Mask and /SMask entries of public
Internet Archive scans, 7 were refused at that default. With the fix all 403
decode, every one bit-exact with poppler's own decoder.

The dependency also stops being untagged.
This package could draw a page and nothing else. A page is the wrong unit for
two jobs.

Getting the pictures out of a document is one, and it is what pdfimages is for.

Finding out whether a codec is right is the other, and it is why this is here
now. A page is a composition: one image decoded wrongly is averaged away by
everything drawn over and around it, so a per-page difference of a few percent
says nothing about WHICH image was wrong. That is not hypothetical. v0.12.0
went out drawing scanned pages dark because what was measured was "ink
appeared" rather than "the right ink", and a per-page number is what let it
through.

Images returns each picture with the name the page draws it by, the image
filter it was stored in — which the pixels cannot tell you and a codec
comparison must know — and whether it is a stencil, whose shape comes back
without a colour because the colour is not the image's to know.

Forms are followed, as pdfimages follows them: a picture reachable only
through one is still a picture the page draws. A document may say a form holds
itself, so the walk stops after eight levels.

The names are walked in order. A map hands its keys back differently every
run, and a list of pictures that reorders itself is not a measurement — that
has already cost this repository a day, in a filter table that answered five
different ways in eight runs.

100% statement coverage, go vet and -race clean, nine cross-compile targets.
@tannevaled
tannevaled merged commit b885cc0 into main Aug 29, 2026
1 check passed
@tannevaled
tannevaled deleted the page-images branch August 29, 2026 09:14
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