Skip to content

Paint images via Engine.LoadImages (closes both image gaps) - #2

Merged
tannevaled merged 1 commit into
mainfrom
paint-images
Sep 4, 2026
Merged

Paint images via Engine.LoadImages (closes both image gaps)#2
tannevaled merged 1 commit into
mainfrom
paint-images

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

  • Paints raster ``, `` and inline `` — the two gaps the README documented — by calling the engine's own fetch/decode/size pipeline (`Engine.LoadImages`, exported in feat(engine): export LoadImages for non-raster painters go-webengine/engine#114) rather than re-implementing it: its size map feeds `layout.LayoutDocument`, its bitmap map feeds the PDF painter, so images are laid out and drawn exactly as the engine's raster canvas would.
  • `Options.BaseURL` resolves a relative `src`; a failed fetch/decode leaves the element out. This is the one place `Export` touches the network.
  • Pins go-webengine/engine to the merged #114 commit; drops the temporary local `replace` used while that PR was in flight.

Corpus evidence (`corpus/CORPUS.md`)

Embedded image XObjects: Wikipedia (Go) 30, countries 10, go.dev/blog 40, HN 6, pkg.go.dev 88, react.dev 166; text length unchanged on every page. Wikipedia's logo and react.dev's logo/icons verified in place on the page-1 previews. Two costs recorded: react.dev → 12 pages / 9 MB (166 icon SVGs as raw FlateDecode RGB, no bitmap dedup yet — next saving), and Render time is now network-bound for image-bearing pages.

Test plan

  • `TestExportEmbedsAnImage`, `TestExportInlineSVGIsRasterisedAndEmbedded`, `TestExportSkipsAnUnfetchableImage`, `TestExportRelativeImageResolvesAgainstBaseURL`, `TestPaintImageIgnoresAnItemWithNoBitmap` — all offline via data: URIs
  • `go test ./...` green (library 96.9%, `paintImage` 100%); gofmt/vet clean; corpus module builds
  • Full 8-page corpus re-run, 8/8 rendered

🤖 Generated with Claude Code

…dImages

Both image gaps the README documented close in one step. Rather than
re-implement fetch/decode/budgeting here, Export calls the engine's own
pipeline — Engine.LoadImages, exported for exactly this in
go-webengine/engine#114 — hands its intrinsic-size map to
layout.LayoutDocument and its bitmap map to the PDF painter. An image is
therefore laid out at, and drawn at, precisely the size the engine's raster
canvas would use, and an inline <svg> arrives already rasterised by the same
path. Options.BaseURL resolves a relative src; a failed fetch/decode leaves
that element out, as on the raster canvas. This is the one place Export
touches the network.

Corpus, this run: embedded image XObjects — Wikipedia (Go) 30, countries
list 10, go.dev/blog 40, Hacker News 6, pkg.go.dev/net/http 88, react.dev
166; text length unchanged on every page. Two costs recorded in CORPUS.md:
react.dev grew to 12 pages / 9 MB (166 icon SVGs stored as raw FlateDecode
RGB, no bitmap dedup yet — the obvious next saving), and the Render column
is now network-bound for image-bearing pages since fetch runs inside Export.

Also pins go-webengine/engine to the merged #114 commit and drops the
temporary local replace used during development.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 58f7cbb into main Sep 4, 2026
1 check passed
@tannevaled
tannevaled deleted the paint-images branch September 4, 2026 14:07
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