Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

ImageSharp 4.1.3 misclassifies linear RGB ICC profiles as sRGB

未关闭
#3,216 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
csharp
领域
backend

调研方向

The suspected cause is IsCanonicalSrgbMatrixTrc() in src/ImageSharp/Metadata/Profiles/ICC/IccProfile.SRGB.cs, which compares the red, green and blue curves but not whether they are the sRGB transfer function. Start with the reproduction ZIP linked in the issue and run it in both DEBUG and RELEASE to see the four failing assertions. Done means linear gamma=1 profiles are not classed as sRGB, Convert produces the expected pixel values, and Compact keeps the profile.

由索引模型根据 Issue 内容生成。

描述

needs triage
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.3

Other ImageSharp packages and versions

None

Environment (Operating system, version and so on)

Ubuntu WSL2, Linux x64, .NET SDK 10.0.112

.NET Framework version

.NET 10.0.12

Description

ImageSharp 4.1.3 incorrectly classifies certain linear RGB ICC profiles as canonical sRGB.

When decoding JPEG or PNG images containing a linear RGB ICC profile with sRGB primaries and gamma=1, ColorProfileHandling.Convert removes the ICC profile without converting the pixel values to sRGB.

PNG:
Actual RGB: [32,64,128]
Expected sRGB: [99,137,188]

JPEG:
Actual RGB: [40,80,120]
Expected sRGB: [110,152,182]

The expected values were independently verified using Little CMS 2.17.

ColorProfileHandling.Compact also incorrectly removes the non-sRGB ICC profile while leaving the RGB values unchanged.

The defect occurs immediately after Image.Load returns, before orientation correction, metadata removal or output encoding.

The issue reproduces identically in both DEBUG and RELEASE configurations with .NET 10.

Suspected cause:
The IsCanonicalSrgbMatrixTrc() method checks that the red, green and blue tone reproduction curves match, but does not verify that they implement the actual sRGB transfer function. Therefore, identical linear gamma=1 curves may be incorrectly classified as canonical sRGB.

Source:
https://github.com/SixLabors/ImageSharp/blob/v4.1.3/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.SRGB.cs

Impact:
This defect can cause incorrect photographic colors when an ICC profile is removed without performing the necessary color transformation.

Could the maintainers confirm this issue and advise whether a fix or officially supported workaround is available for ImageSharp 4.1.x?

Steps to Reproduce

Steps to reproduce:

  1. Use SixLabors.ImageSharp 4.1.3 with .NET 10 on Linux x64 (Ubuntu WSL2).

  2. Extract the attached reproduction ZIP into a clean directory and follow its README instructions. Use a valid Six Labors license stored outside the project.

  3. Restore the locked NuGet dependencies and compile the reproduction project.

  4. Run the reproduction in both DEBUG and RELEASE configurations.

  5. The supplied synthetic JPEG and PNG images contain an ICC v4.3 RGB profile with sRGB primaries and linear gamma=1 transfer curves.

  6. Load the images using Image.Load with ColorProfileHandling.Convert, Compact and Preserve.

  7. Inspect the RGB pixel values and ICC profile immediately after decoding.

  8. Compare the results against the expected sRGB values independently verified using Little CMS 2.17.

Expected versus actual results:

PNG Convert:
Expected RGB: [99,137,188]
Actual RGB: [32,64,128]
ICC: Absent in both cases.

JPEG Convert:
Expected RGB: [110,152,182]
Actual RGB: [40,80,120]
ICC: Absent in both cases.

PNG Compact:
Expected RGB: [32,64,128]
Actual RGB: [32,64,128]
Expected ICC: Present
Actual ICC: Absent

JPEG Compact:
Expected RGB: [40,80,120]
Actual RGB: [40,80,120]
Expected ICC: Present
Actual ICC: Absent

Verification:

The defect reproduces identically in DEBUG and RELEASE.

Two Preserve control assertions pass.
Four assertions fail.
Exit code 1 is intentional because the tests detect the defect.

The problem occurs immediately after Image.Load returns, before orientation correction, metadata removal or PNG encoding.

The attached ZIP contains the minimal .NET 10 project, synthetic JPEG/PNG/ICC fixtures, instructions, expected results and SHA-256 hashes.

No license credentials, customer images or proprietary code are included.

Images

imagesharp-4.1.3-linear-icc-repro.zip

主要语言
C#
星标
8k
派生
904
平均合并
15 小时 39 分钟
30 天内合并 PR
12

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

SixLabors/ImageSharp 的其他 Issue

查看 SixLabors/ImageSharp 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。