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

Reading incorrect color data when JpegColorType is Rgb. #2141

Closed
4 tasks done
CryShana opened this issue Jun 4, 2022 · 2 comments
Closed
4 tasks done

Reading incorrect color data when JpegColorType is Rgb. #2141

CryShana opened this issue Jun 4, 2022 · 2 comments

Comments

@CryShana
Copy link

CryShana commented Jun 4, 2022

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

2.1.2

Other ImageSharp packages and versions

SixLabors.ImageSharp 2.1.2

Environment (Operating system, version and so on)

Windows 11 and Ubuntu 20.04.4 LTS

.NET Framework version

.NET 6 (SDK 6.0.300)

Description

JPEG images with ColorType value of JpegColorType.Rgb have their color values read/parsed incorrectly.

Though such images are rare, I encountered multiple such images already and all of them were read incorrectly. Other image readers and tools read them correctly.

Example code:

using var image = Image.Load(filePath);

var colorType = image.Metadata.GetJpegMetadata().ColorType;
if (colorType == JpegColorType.Rgb)
{
    // colors will be read wrong
}

// you can save it as anything, doesn't matter
image.SaveAsJpeg("output.jpg");

Just to get an idea of how colors change with an example input image. This is the original:
input

The output is this:
output

Steps to Reproduce

This works on any JPEG image that has ColorType = JpegColorType.Rgb

  • Load any such image by using Image.Load(filepath); or Image.Load<Rgba32>(filepath);
  • You can try reading some pixels to confirm the colors are off
  • Save image using any method, I used image.SaveAsJpeg(outputPath);

The output should be very different from the input.

Images

Original (input image):
input

@brianpopow
Copy link
Collaborator

brianpopow commented Jun 4, 2022

@CryShana this is probably already fixed with #2135. Can you try our nightly build form the MyGet feed?

Related issue #2133

@CryShana
Copy link
Author

CryShana commented Jun 4, 2022

Ah, you are correct. I just checked out the 3.0.0-alpha.0.11 version of ImageSharp and it works now.

Do I close this issue?

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

3 participants