-
-
Notifications
You must be signed in to change notification settings - Fork 888
Closed
Labels
Description
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
DEBUGandRELEASEmode - 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:

Steps to Reproduce
This works on any JPEG image that has ColorType = JpegColorType.Rgb
- Load any such image by using
Image.Load(filepath);orImage.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.

