ImageSharp icon indicating copy to clipboard operation
ImageSharp copied to clipboard

WebP encoding produces a 100% transparent image

Open Lovrenc opened this issue 1 year ago • 3 comments

Prerequisites

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

ImageSharp version

3.1.5

Other ImageSharp packages and versions

/

Environment (Operating system, version and so on)

Windows 11 23H2

.NET Framework version

7.0

Description

WebP encoding produces an entirely transparent image.

It seems that quality settings, lossy or lossless or EncodingMethod Level had no effect (I tested about 20 combinations).

Decoding looks ok, if I export the same image as JPEG it works fine.

Steps to Reproduce

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


var path = "d:\\";
var img = Image.Load($"{path}bugged_image.webp");
var encoder = new WebpEncoder()
{
    Quality = 65,
    FileFormat = WebpFileFormatType.Lossy,
    TransparentColorMode = WebpTransparentColorMode.Preserve,
    Method = WebpEncodingMethod.Level2
};
await img.SaveAsync($"{path}bugged_image_result_direct.webp", encoder);

Images

bugged_image.zip

Lovrenc avatar Aug 28 '24 12:08 Lovrenc

I don't think this is the encoder., I think it's the decoder. If you save the image as a PNG the same occurs.

JimBobSquarePants avatar Aug 29 '24 00:08 JimBobSquarePants

Confirmed. It's the lossy decoder. Something is failing there when applying the alpha values to the pixels. We're getting zero for everything.

JimBobSquarePants avatar Aug 29 '24 05:08 JimBobSquarePants

Found the issue, will PR soon.

JimBobSquarePants avatar Oct 15 '24 14:10 JimBobSquarePants