Trim
Trim

Reputation: 373

Identifying Color profile of jpeg in C#

I use a lib that manipulates PDF files called PDF4Net by o2Solutions. I have an issue on XP and Server 2003 where the lib doesn't properly identify the colorspace of images and incorrectly draws them on the page, skewing the image. You can specify the colorspace of an image to be drawn explicitly, and I'm attempting to programmatically figure out what colorspace an image is in. I stumbled upon:

How to detect if a jpeg contains cmyk color profile?

I used the function:

protected bool isFileACMYKJpeg(System.Drawing.Image someImage)
{
    System.Drawing.Imaging.ImageFlags flagValues = (System.Drawing.Imaging.ImageFlags)Enum.Parse(typeof(System.Drawing.Imaging.ImageFlags), someImage.Flags.ToString());
    if (flagValues.ToString().ToLower().IndexOf("ycck") == -1)
    {
        return false;
    }
    return true;
}

However it only returns RGB even though the jpeg is in CMYK. Any thoughts on how to get around this?

Upvotes: 4

Views: 1016

Answers (1)

alc
alc

Reputation: 1557

Have you tried something like this?

protected bool isFileACMYKJpeg(System.Drawing.Image someImage)
{
  return someImage.Flags.HasFlag(System.Drawing.Image.ImageFlags.ColorSpaceCmyk);
}

Upvotes: 4

Related Questions