Skip to content

Webp encoding produces completely transparent images #2763

Description

@Lovrenc

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

3.1.4

Other ImageSharp packages and versions

Not using

Environment (Operating system, version and so on)

Windows 11/Ubuntu 22.04

.NET Framework version

.net 7.0

Description

Webp encoder in some instances produces a completely transparent image (the image still has 262KB tho, so I guess the data is in there.

Attached you have a code to reproduce the issue and a sample image.

Important notes:
Changing encoding quality produces a valid image.
Changing the encoding method also produces a valid image (however, I found faster encoding levels tend to produce artifacts on fade-out transparencies)

Steps to Reproduce

// See https://aka.ms/new-console-template for more information

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Webp;


var path = "d:\\";
var img = Image.Load($"{path}bugged_image.png");
var encoder = new WebpEncoder()
{
    Quality = 85,
    Method = WebpEncodingMethod.Level4
};
await img.SaveAsync($"{path}bugged_image_result_direct.webp", encoder);

Images

bugged_image

Activity

  1. JimBobSquarePants commented on Jul 4, 2024

    @JimBobSquarePants
    Member

    Important notes:
    Changing encoding quality produces a valid image.
    Changing the encoding method also produces a valid image (however, I found faster encoding levels tend to produce artifacts on fade-out transparencies)

    @Lovrenc Can you please give examples at which the quality works?

  2. JimBobSquarePants commented on Jul 4, 2024

    @JimBobSquarePants
    Member

    OK. This is odd...

    I can replicate the issue with the v3.1.4 release NuGet package but I cannot replicate it with the release/3.1.x branch without explicitly setting the encoder to use Lossless encoding (though there are no commits changing behavior).

    It appears quality between greater than 83 and less than 88 causes the issue. It's something to do with symbol generation in the VP8LEncoder but I'm not sure what is happening. @brianpopow I likely need your experience here if you have time.

  3. Lovrenc commented on Jul 4, 2024

    @Lovrenc
    Author

    Important notes:
    Changing encoding quality produces a valid image.
    Changing the encoding method also produces a valid image (however, I found faster encoding levels tend to produce artifacts on fade-out transparencies)

    @Lovrenc Can you please give examples at which the quality works?

    Sorry I was not around.

    I see you found a range.

    I can confirm that values 60, 70, and 75 work, and 85 does not work; I did not test other values.

  4. brianpopow commented on Jul 4, 2024

    @brianpopow
    Collaborator

    It appears quality between greater than 83 and less than 88 causes the issue. It's something to do with symbol generation in the VP8LEncoder but I'm not sure what is happening. @brianpopow I likely need your experience here if you have time.

    @JimBobSquarePants I will take a look into this on the weekend.

  5. JimBobSquarePants commented on Jul 6, 2024

    @JimBobSquarePants
    Member

    It appears quality between greater than 83 and less than 88 causes the issue. It's something to do with symbol generation in the VP8LEncoder but I'm not sure what is happening. @brianpopow I likely need your experience here if you have time.

    @JimBobSquarePants I will take a look into this on the weekend.

    Thanks. I spent a few hours comparing our code to libwebp and couldn’t spot an issue.

  6. added a commit that references this issue on Jul 9, 2024
    00b253d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions