我假设你展示的CMYK值是以百分比表示的(100/0/0/0)。在Imagemagick命令行中,您可以执行以下操作来创建样本:
convert xc:"cmyk(100%,0%,0%,7%)" -profile /Users/fred/images/profiles/ISOcoated_v2_300_eci.icc -profile /Users/fred/images/profiles/sRGB.icc -scale 100x100! test.png
或者你可以按照以下方式获取返回值:
convert xc:"cmyk(100%,0%,0%,7%)" -profile /Users/fred/images/profiles/ISOcoated_v2_300_eci.icc -profile /Users/fred/images/profiles/sRGB.icc -format "%[pixel:u.p{0,0}]\n" info:
srgb(0%,61%,81%)
如果您想使用0到255的值而不是百分比,请添加-depth 8。
convert xc:"cmyk(100%,0%,0%,7%)" -profile /Users/fred/images/profiles/ISOcoated_v2_300_eci.icc -profile /Users/fred/images/profiles/sRGB.icc -depth 8 -format "%[pixel:u.p{0,0}]\n" info:
srgb(0,156,207)
您也可以使用介于0和255之间的值开始。
convert xc:"cmyk(255,0,0,17.85)" -profile /Users/fred/images/profiles/ISOcoated_v2_300_eci.icc -profile /Users/fred/images/profiles/sRGB.icc -depth 8 -format "%[pixel:u.p{0,0}]\n" info:
srgb(0,156,207)
你可以通过RMagick来实现这个,但我不是RMagick的专家。不过可以看看sambecker
的其他帖子。