Skip to content

Grayscale Icc profile color #3197

Description

@IAMManuel

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions