You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oversized rasters are already shown far smaller than their natural size, so
targeting a fraction below the visible resolution (RES_FACTOR, applied only after
the oversize guard) shaves extra decode/raster work at an imperceptible cost on
the common heavy-image case. ~-44% toCanvas / -96% SVG output on the image
gallery, mean pixel diff < 1/255.
Applies via the shared downsampleDataURL core, so <img>, CSS backgrounds and
SVG <image> all benefit. README wording updated to 'imperceptible in practice'.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Inlined raster images are embedded at their full natural resolution even when shown in a small box — pixels the output can never display, which only bloat the payload and slow rasterization. With `compress` (on by default) SnapDOM downsamples each `<img>`to the resolution actually visible (`display box × scale × dpr`), preserving aspect ratio and never upscaling. The source codec is kept, so PNGs stay lossless and fidelity is preserved.
373
+
Inlined raster images are embedded at their full natural resolution even when shown in a small box — pixels the output can never display, which only bloat the payload and slow rasterization. With `compress` (on by default) SnapDOM downsamples each oversized raster to (a touch below) the resolution actually visible (`display box × scale × dpr`), preserving aspect ratio and never upscaling. The source codec is kept (PNGs stay lossless), and because the image was already shown far smaller than its natural size the quality loss is imperceptible in practice. Images already at or below their visible size are left untouched. Covers `<img>` (incl. cloned canvas/video), non-repeating CSS `background-image`, and SVG `<image>`.
0 commit comments