Menu

#737 WebP: Colors not preserved in fully-transparent areas

v1.0_(example)
closed-fixed
None
5
2024-04-23
2024-04-17
No

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

4 Attachments

Discussion

  • Alex Kent Hajnal

    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.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2024-04-20
    • assigned_to: Bob Friesenhahn
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2024-04-20
    • status: open --> closed-fixed
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2024-04-20

    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.

     
  • Alex Kent Hajnal

    Works perfectly. Thanks!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.