SixLabors / SixLabors/ImageSharp

Grayscale Icc profile color

Open
#3,197 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs triage
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 DEBUG and RELEASE mode
  • 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
Image
test_image_with_gray_icc_profile.converted.jpg
Image
test_image_with_gray_icc_profile.preserve.jpg
Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.