I have tried using both imagemagick and The GIMP to convert a PNG to WEBP, but the text colors tend to fade after conversion.
Is there any way to tell WEBP to keep the colors strong?
The problem is most noticeable with lower resolution images, and with fully saturated primary colors.
Yes! There are a bunch of options we can pass to the WEBP encoder through imagemagick.
After some experimentation, I found the option
use-sharp-yuv=truekept the color saturation and intensity high, how I expected.Using this option has a similar effect for lower quality conversions.
Disadvantages
But for my purposes, I find enabling this option produces a result closer to the original.
Alternatives
The
lossless=trueoption can also preserve the colors, but this prevents you from significantly reducing the filesize by tuning the quality.Example
Original image (22.9K PNG):
Standard conversion to WEBP (18.1K, you can see that the colored text has faded, especially the thin magenta and dark blue characters):
Conversion to WEBP with
use-sharp-yuvoption enabled (21.3K, but colors are better):