Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WEBP] Creating lossy webp from this png produces corrupted webp file #2920

Copy link
Copy link

Description

@mikethea1
Issue body actions

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.8

Other ImageSharp packages and versions

n/a

Environment (Operating system, version and so on)

Windows 11 x64, also reproduced on Amazon Linux x64

.NET Framework version

8

Description

When this .png file is converted to .webp using ImageSharp, it produces a corrupted webp image:

Screenshot of corrupted webp file as viewed in chrome:

Image

I did look at #2068 which seemed like a similar issue but the problem ended up being their environment. In my case, I'm able to reproduce with a minimal reproduction as shown below. I won't rule out that I'm doing something wrong, but I'm not seeing anything and my webp conversion code works beautifully otherwise.

EDIT: I think this is caused by the image having dimensions greater than the max webp supports (16383). So the issue might be more one of argument validation/throwing a clear error message rather than a flaw in the encoding algorithm.

Steps to Reproduce

Repro code:

var path = @"path\to\repro.png";
using var image = SixLabors.ImageSharp.Image.Load(path);
using var outputStream = File.OpenWrite(path + ".webp");
image.Save(outputStream, new WebpEncoder { Quality = 75, Method = WebpEncodingMethod.Fastest, FileFormat = WebpFileFormatType.Lossy });

Images

Input and output files (had to zip since neither would upload directly):

repro.zip

Reactions are currently unavailable

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

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.