A 90 KB thumbnail looks like a win until you put it on the dark theme and notice a fuzzy border around the icon. For a photograph that might be harmless. For a screenshot that explains where to click, the lost edge might be the point of the image.
Image compression for UI assets needs a different test from photo compression. Keep the dimensions fixed, compare two encodings, and look at the places most likely to break.
Make two candidates from the same source
Pick a PNG screenshot or an exported UI illustration with fine text and, if relevant, transparent edges. Save it as panel.png. Use the cwebp command from libwebp:
cwebp -lossless -q 80 panel.png -o panel-lossless.webp cwebp -q 82 -alpha_q 100 panel.png -o panel-lossy.webp wc -c panel.png panel-lossless.webp panel-lossy.webp The first command compares a lossless WebP with the source PNG. The second allows loss in the color data while keeping alpha compression lossless. That doesn’t guarantee clean edges: edge pixels still contain color information, so check how the result blends against its real background.
Also, the two -q values don’t mean the same thing. In lossy mode the flag controls the quality trade-off. In lossless mode it trades encoding time against file size. Check the cwebp reference before turning these commands into defaults.
Compare the candidates on light and dark backgrounds
Save this as compare.html next to the two WebP files. Open it in a browser at normal zoom. The button changes the stage behind both images without changing their dimensions.
<!doctype html> <html lang="en"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>UI image comparison</title> <style> body { font: 16px system-ui; margin: 1rem; } #stage { background: white; color: #111; } #stage.dark { background: #161b22; color: #eee; } figure { margin: 0; padding: 1rem; } img { display: block; width: min(100%, 600px); height: auto; } </style> <button id="theme" type="button" aria-pressed="false">Dark background</button> <main id="stage"> <figure> <img src="panel-lossless.webp" alt="UI detail encoded as lossless WebP"> <figcaption>Lossless WebP</figcaption> </figure> <figure> <img src="panel-lossy.webp" alt="The same UI detail encoded as lossy WebP"> <figcaption>Lossy WebP</figcaption> </figure> </main> <script> const stage = document.querySelector('#stage'); const button = document.querySelector('#theme'); button.addEventListener('click', () => { const dark = stage.classList.toggle('dark'); button.setAttribute('aria-pressed', String(dark)); }); </script> </html> Set the width to match the space the asset actually occupies. Check the smallest label, any one-pixel lines, and the edges of shadows or transparent icons. If the source is fully opaque, the background toggle won’t affect it; compare the text and lines instead. For an extra sanity check, add the original PNG to the same page.
Let the acceptance criteria pick the file
Use the smallest candidate that still does its job. If lossy WebP makes the label harder to read, use the better-looking lossless option. If the original PNG is already smaller than both acceptable exports, keep it. The format name isn’t the result; the byte count and the rendered asset are.
If you’re preparing a few non-sensitive assets, VideoCompress’s online image compressor can produce another candidate for comparison. Check the download’s format and dimensions before adding it to the test page, then inspect it against the same light and dark backgrounds.
Use a real screenshot for the test. A smooth photo won’t tell you whether your settings damage a caret, a price, or the thin border that shows which input has focus.

