Does anybody know how to properly identify CMYK images using C#? I found how to do it using ImageMagick, but I need a .NET solution. I found 3 code snippets online, only one works in Windows 7, but all fail in Windows Server 2008 SP2. I need it to work at least in Windows Server 2008 SP2. Here is what I've found:
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Drawing;
using System.Drawing.Imaging;
bool isCmyk;
// WPF
BitmapImage wpfImage = new BitmapImage(new Uri(imgFile));
// false in Win7 & WinServer08, wpfImage.Format = Bgr32
isCmyk = (wpfImage.Format == PixelFormats.Cmyk32);
// Using GDI+
Image img = Image.FromFile(file);
// false in Win7 & WinServer08
isCmyk = ((((ImageFlags)img.Flags) & ImageFlags.ColorSpaceCmyk) ==
ImageFlags.ColorSpaceCmyk);
// true in Win7, false in WinServer08 (img.PixelFormat = Format24bppRgb)
isCmyk = ((int)img.PixelFormat) == 8207;