SixLabors / SixLabors/ImageSharp
Grayscale Icc profile color
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 8k
- Forks
- 899
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 7
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
4.1.2
Other ImageSharp packages and versions
- SixLabors.ImageSharp.Drawing 3.1.0 - SixLabors.ImageSharp.Web 4.0.1
Environment (Operating system, version and so on)
Windows 11
.NET Framework version
.NET 10.0
Description
When loading a JPEG image with an embedded grayscale ICC profile using ColorProfileHandling.Convert, the image is rendered incorrectly. The colors are flattened to a uniform light gray instead of preserving the original grayscale tones. However, when using ColorProfileHandling.Preserve, the image renders correctly with the expected gray tones.
The issue appears to be in the ICC profile conversion logic when handling grayscale color spaces. The conversion from the grayscale ICC profile to sRGB is not producing the correct pixel values.
Steps to Reproduce
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats;
// Load image with ColorProfileHandling.Convert (INCORRECT - flattens to light gray)
using var imgConvert = Image.Load(new DecoderOptions
{
ColorProfileHandling = ColorProfileHandling.Convert,
}, "test_image_with_gray_icc_profile.jpg");
imgConvert.Save("converted.jpg");
// Load image with ColorProfileHandling.Preserve (CORRECT - preserves gray tones)
using var imgPreserve = Image.Load(new DecoderOptions
{
ColorProfileHandling = ColorProfileHandling.Preserve,
}, "test_image_with_gray_icc_profile.jpg");
imgPreserve.Save("preserve.jpg");
Images
test_image_with_gray_icc_profile.jpg
test_image_with_gray_icc_profile.converted.jpg
test_image_with_gray_icc_profile.preserve.jpg
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided C# example and attached grayscale ICC-profile JPEG, comparing ColorProfileHandling.Convert with Preserve. Trace the ICC profile conversion path for grayscale color spaces; done means Convert preserves the source image's grayscale tones instead of flattening them to light gray.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100