C#判断图片是CMYK模式还是RGB模式最简单的方法:
Image img = Bitmap.FromFile("图片路径", true);
PixelFormat pf = (PixelFormat)img.PixelFormat;
if (pf.ToString() == "8207")
{
MessageBox.Show("图片是CMYK模式!");
}
因为img.PixelFormat的返回值为Format8bppIndexed 灰度模式,在遇到RGB等其他颜色模式时返回“Format24bppRgb”,但是在遇到CMYK模式的图片是返回“8207”。