Indie dev efficiency4 min read

Lossless WebP: Check RGB Under Fully Transparent Pixels

Compare two lossless WebP exports to see whether invisible RGB needs to survive your game asset handoff.

Lossless WebP: Check RGB Under Fully Transparent Pixels
A magnified gem edge reveals hidden color underneath fully transparent pixels
Concept illustration

A PNG and its lossless WebP copy look identical, yet your pixel diff flags a change. Split the diff by alpha before calling it a quality problem. A fully transparent pixel can store a color you never see in a normal preview. The following test concerns static RGBA assets encoded with libwebp's cwebp.

Build a fixture with deliberate invisible colors

In a small RGBA PNG, include an opaque blue pixel, a partially transparent cyan pixel, and two fully clear pixels with distinct nonzero RGB values. Use a reader that reports raw, unpremultiplied channels to confirm the PNG still contains those values. Some editors remove them on export, making the fixture useless for this test.

Encode the same source with and without exact mode

cwebp -lossless fixture.png -o normal.webp
cwebp -lossless -exact fixture.png -o exact.webp

Decode both files into unpremultiplied RGBA. Compare the alpha plane, the colors of visible or partially visible pixels, and the RGB under zero alpha separately. The default lossless encoder may change invisible colors; a difference at any particular pixel is not guaranteed. Exact mode asks the encoder to preserve those colors. A screenshot or canvas readback that has already gone through premultiplication cannot reliably tell you what RGB was stored beneath zero alpha.

Decide whether the hidden data is part of the delivery

For a finished web preview, compare file size and the visible edge on light and dark backgrounds with the Tooliva asset compression tool. This test does not assume that the online tool exposes cwebp's exact switch. For a source texture that will be edited, checked by a pixel hash, or have its alpha rebuilt, test the full channel data with the actual downstream decoder. Keep the PNG master until that comparison passes. Matching appearance, matching channels and a smaller file are three different acceptance checks.

Ready to try "Lossless WebP: Check RGB Under Fully Transparent Pixels"?

Use our online tools to apply this tutorial to your indie game project right away.