Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webp encoding produces completely transparent images #2763

Closed
4 tasks done
Lovrenc opened this issue Jul 3, 2024 · 5 comments · Fixed by #2767
Closed
4 tasks done

Webp encoding produces completely transparent images #2763

Lovrenc opened this issue Jul 3, 2024 · 5 comments · Fixed by #2767

Comments

@Lovrenc
Copy link

Lovrenc commented Jul 3, 2024

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

@JimBobSquarePants
Copy link
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?

@JimBobSquarePants
Copy link
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.

@Lovrenc
Copy link
Author

Lovrenc commented Jul 4, 2024

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.

@brianpopow
Copy link
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.

@JimBobSquarePants
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants