CMYK JPEG with embedded SWOP profile decodes with lifted dark colors: decoder does not apply black point compensation (differs from Photoshop/ImageMagick)

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
50/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
csharp

调研方向

Start by reading DecoderOptions, the JPEG decoder's ICC profile conversion path, and ColorConversionOptions.UseBlackPointCompensation/ColorProfileConverter. Check existing JPEG decoding and color-profile tests to find where decoder options are applied. Done means decoding this CMYK/YCCK JPEG can use BPC and produces results consistent with the reported BPC reference values.

由索引模型根据 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 and 5.0.0-alpha.0.29 (nightly, build  bce6d79 )

Other ImageSharp packages and versions

none

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

.NET 10.0

Description

Decoding a CMYK (YCCK) JPEG that embeds "U.S. Web Coated (SWOP) v2" produces colors that differ from Photoshop and ImageMagick. Dark colors are noticeably lighter. For example, a near-black charcoal background decodes as RGB (50, 51, 51), where ImageMagick with black point compensation (BPC) gives (25, 28, 28).

The cause is that the decoder converts without BPC.  ColorConversionOptions.UseBlackPointCompensation  exists in 5.0.0-alpha.0.29 and gives the correct result through  ColorProfileConverter , but the JPEG decoder doesn't use it and  DecoderOptions  doesn't expose it. The result is that the same file looks different in ImageSharp than in Photoshop, ImageMagick or other color-managed viewers.

The 5.0 nightly is a big improvement over 4.x. On 4.1.3 the default  Preserve  ignores the profile (colors are oversaturated), and  Convert  gives a bluish charcoal (57, 67, 72). This report is about the remaining difference.

Expected: a way to decode with BPC, or a decoding result that matches the Photoshop and ImageMagick conversion.

Actual: the decoder always gives the non-BPC result.

Steps to Reproduce

ImageMagick reference:
 magick cmyk_swop_exact.jpg -intent relative -black-point-compensation -profile sRGB.icm out.bmp 

The test image is a 1200x800 YCCK JPEG at quality 100, with no chroma subsampling. Each block is an exact CMYK ink value, so the expected values are unambiguous.

Results (sRGB)

Sample ink values (C/M/Y/K %):

Area Ink C/M/Y/K %
Red 0/100/100/0
Blue 100/100/0/0
Green 100/0/100/50
Charcoal 70/60/60/80
Orange 0/45/80/0

ImageSharp 4.1.3 (stable)

Area Preserve (default) Convert
Red 255, 0, 0 237, 51, 56
Blue 0, 0, 255 62, 64, 150
Green 0, 128, 1 0, 108, 63
Charcoal 16, 20, 20 57, 67, 72
Orange 255, 140, 51 248, 160, 82

ImageSharp 5.0.0-alpha.0.29 (nightly)

Area Decoder (no BPC option) ColorProfileConverter, BPC off ColorProfileConverter, BPC on
Red 238, 51, 56 238, 51, 56 237, 28, 36
Blue 63, 64, 150 63, 64, 150 46, 48, 146
Green 0, 108, 63 0, 108, 62 0, 101, 46
Charcoal 50, 51, 51 49, 51, 51 24, 28, 28
Orange 249, 160, 83 249, 161, 84 249, 158, 73

ImageMagick reference

Area ICC, no BPC ICC + BPC
Red 238, 51, 56 237, 28, 36
Blue 63, 64, 150 46, 48, 146
Green 0, 108, 63 0, 101, 46
Charcoal 50, 51, 51 25, 28, 28
Orange 249, 160, 84 249, 157, 73
Images

cmyk_swop_exact_imagesharp_nightly29.bmp
cmyk_swop_exact_imagesharp_Convert.bmp
cmyk_swop_exact_imagesharp_Preserve.bmp
cmyk_swop_exact_imagemagick.bmp
cmyk_swop_exact

主要语言
C#
星标
8.1k
派生
913
平均合并
1 天 30 分钟
30 天内合并 PR
29

环境准备

从这里开始

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

SixLabors/ImageSharp 的其他 Issue

查看 SixLabors/ImageSharp 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

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