Skip to content

Upload web images at their device size and charge only real copies - #616

Merged
Velli20 merged 1 commit into
mainfrom
fix-web-image-upload-budget
Oct 27, 2026
Merged

Velli20 merged 1 commit into
mainfrom
fix-web-image-upload-budget

Conversation

@Velli20

@Velli20 Velli20 commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Uploading an image charged three times its RGBA size against the web
rendering budget: a redundant Rust RGBA copy, the browser ImageData copy,
and the surface. A 4032x3024 photo needed 139.5 MiB of the 128 MiB budget,
so the page failed with "web rendering resource budget exceeded".

RGBA pixels now go to ImageData directly, and only non-RGBA pixels are
converted first. Images are box-reduced before upload to no fewer pixels
than the backing pixels they cover, growing the factor only when needed
to fit the budget, so any image the decoder accepts can be drawn.

The existing box reduction is exposed as pdf_image::ReduceImage.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

Uploading an image charged three times its RGBA size against the web
rendering budget: a redundant Rust RGBA copy, the browser ImageData copy,
and the surface. A 4032x3024 photo needed 139.5 MiB of the 128 MiB budget,
so the page failed with "web rendering resource budget exceeded".

RGBA pixels now go to ImageData directly, and only non-RGBA pixels are
converted first. Images are box-reduced before upload to no fewer pixels
than the backing pixels they cover, growing the factor only when needed
to fit the budget, so any image the decoder accepts can be drawn.

The existing box reduction is exposed as pdf_image::ReduceImage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Velli20
Velli20 merged commit bbd67ec into main Oct 27, 2026
10 checks passed
@Velli20
Velli20 deleted the fix-web-image-upload-budget branch October 27, 2026 20:52
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