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

File conversion from jpg to webp changes colors of the image #2723

Open
4 tasks done
WimAtIHomer opened this issue Apr 22, 2024 · 1 comment
Open
4 tasks done

File conversion from jpg to webp changes colors of the image #2723

WimAtIHomer opened this issue Apr 22, 2024 · 1 comment

Comments

@WimAtIHomer
Copy link

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

none

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

6 and 8

Description

In our application we resize and change images from png and jpg to webp for better performance on the website. This works very good most of the times. But for some jpg images there is a distinct color change.
It might be related to #1567 but I am not sure, doesn't happen when just resizing the jpg image.

Steps to Reproduce

using var image = await Image.LoadAsync(file.OpenReadStream());
using var outStream = new MemoryStream();
await image.SaveAsync(outStream, new WebpEncoder());

Jpg image:
3_VMware Better Together

webp image looks like this (see webp in zip):
VMware Better Together

Images

VMware Better Together.zip

@JimBobSquarePants
Copy link
Member

OK.... This is an interesting issue.

The JPEG has a CMYK ICC profile and is encoded using YCCK colors.
When we convert to RGB, the colors are decoded as in the WEBP output. Since we don't then reverse the operation (WEBP encodes as BGR (optional A)) the colors are incorrectly encoded. We preserve the color type as JPEG metadata so encoding reverses the decode color transform and produces a much closer result.

The fix would be to have #1567 working and convert to RGB using the profile as a guide. When that will ever happen, I simply do not know. I need help there.

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

No branches or pull requests

2 participants