slides: photos shrink at insert — 2560 px cap, lossy for photos, lossless for graphics - #477
Merged
Merged
Conversation
…less for graphics A phone photo is 4000 px wide and several MB; a slide is 1280 wide. Every image insert (file picker, paste, panel replace) now goes through editor/shrink.ts: the long edge is capped at 2560 (crisp on 4K), photos are re-encoded JPEG/WebP 0.85, and graphics — anything transparent, a flat-background screenshot, a few-colour logo — are only downscaled, never lossy. The original bytes are kept unless the result is at least 20% smaller; SVG and GIF are never touched. A toast says what happened when the saving is 200 KB or more. The picture panel shows what is stored (Embedded · size · pixels) and offers Replace file (original size)… for every pixel; About carries Shrink photos on insert (localStorage, this browser). Format untouched: a picture is still a data URI or an asset: key; model.ts unchanged. Rig scripts/test-slides-shrink.ts (33 checks), registered in CI.
Build size
Updated: |
…ides' strings and rigs kept; aspect-lock rig reads the whole Picture section
nyblnet
added a commit
that referenced
this pull request
Sep 14, 2026
…o shrink): both sides kept; shrink rig asks the format directly instead of diffing model.ts against main
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The next file-size lever after #447/#476 (a save drops what nothing refers to) and #468 (built-in fonts): the picture that gets pasted in the first place. A phone photo is ~4000 px and several MB; a slide is 1280 px wide. Format untouched —
srcis still a data URI or anasset:key;model.tsunchanged (asserted by the rig).UX, as the maintainer approved it: lossy for photos, 2560 px cap, toast only when it matters.
slides/src/editor/shrink.ts.Photo stored at 2560 px — 11.2 MB → 139 KB(or Image stored… for a graphic); otherwise the usual "Image pasted".Embedded · 18 KB · 800×600, Replace file… (shrunk) and Replace file (original size)… (every pixel, the honest way out). About: Shrink photos on insert checkbox,localStorage 'bento-shrink-photos', this browser only, never in the document.Measured in Chrome on the built shell, through the real paste handler (
ClipboardEventwith aDataTransferfile):Picture panel on a stored image reads
Embedded · 18 KB · 800×600with both Replace buttons; the About checkbox writesoff/on. Timing in a visible tab: the 11 MB photo took 1.5 s end to end.Rig
scripts/test-slides-shrink.ts— 33 checks: photo / sky / screenshot / logo / alpha classification and the exact flat-run threshold, the grid sampler, the keep rule at 19% vs 21%, the cap arithmetic, untouchable formats, the toast threshold and wording, every insert path routed through the shrink, the About switch, andgit diff origin/main -- slides/src/model.tsempty. Negative control: breaking the keep rule goes red. Registered in CI after the fields rig;test-ci-registered328/328. 9 strings × 8 catalogs + 22 packs, coverage 100%; typecheck, modelkeys green. CHANGELOG entry under [Unreleased].Not done: nothing retroactive — an existing deck's pictures are untouched until something new is inserted. A deliberate Compress pictures in this deck… action can follow if wanted.