When converting an image to WebP that contains fully-transparent pixels then the color values in the fully-transparent areas are lost. (When converting to PNG the color values are preserved.) Expected behavior is to preserve the pixel values (especially when saving as lossless).
I understand that the rationale for discarding color values in fully-transparent pixels is done to improve the compression ratio. I propose adding a flag to specify the desired behavior. With ImageMagick, it appears that specifying "-define webp:exact=true" will save colors of fully transparent pixels (the default value is false). If this flag is used in GraphicsMagick then I propose changing the behavior such that the default is true when using saving a lossless WebP image.
The attached files show the behavior:
• alpha-test.png → Original image. Smooth gradient with two transparent area (feathered and hard-edge)
• alpha-test-opaque.png → Original image made opaque using GIMP's unerase tool
• alpha-test.webp → Output of "gm convert alpha-test.png -define webp:lossless=true alpha-test.webp"
• alpha-test-opaque.webp → alpha-test.webp made opaque using GIMP's unerase tool
Looking through the libwebp code (webp/src/encode.h to be specific) it looks like it should be a simple matter of setting WebPConfig.exact to 1. Also, I retract my previous suggestion of changing the default to true since with both IM and cwebp the default is false in all cases.
Support for this feature has been implemented exactly as you describe. The changes are in Mercurial changeset 17477:5d3f35e77f30 and will be in the next development snapshot.
Works perfectly. Thanks!