Determine color mode

Jun 2, 2014 at 1:01 PM
Edited Jun 2, 2014 at 1:05 PM
I can't seem to retrieve the actual color mode of an image. Each of the following two images has a different color mode:
    ExifTool shows me:
                                 Color Mode                      : RGB
                                 ICC Profile Name             : Adobe RGB (1998)
    ExifTool shows me:
                                 Color Mode                      : Grayscale
                                 ICC Profile Name            : Gray Gamma 2.2
However when I use the following code on both, the resulting object (magickImageSource ) shows that the ColorSpace is Gray and ColorType is Greyscale. Shouldn't image #1 show me RGB?
    MagickImage magickImageSource = new MagickImage(sourceFilePath);
Jun 2, 2014 at 1:21 PM
Exif tool reports information from the exif profile. When I run ImageMagick with a debugger in Visual Studio I can see the tiff photometric is 'Grayscale or bi-level, black is 0' ( And that is why the color space is gray.
Jun 2, 2014 at 1:36 PM
Edited Jun 2, 2014 at 1:41 PM
The reason I'm asking is because when I convert each .tif to a .jpg, I get an"Embedded IOC invalid profile" error when opening up the resulting image in Photoshop. I can avoid this issue by forcing the ColorType to be RGB on image #1 or forcing the ColorType to be Gray for image #2. But it appears that the resulting object (magickImageSource ) looks identical for both. How can I determine which images need to be RGB and which ones need to be Gray when I convert? Or is there a more generic way to handle that. I know that the following line of code results in null for both as well so I don't think I can read that:

ExifProfile ep= magickImageSource.GetExifProfile();

Also, the object (magickImageSource ) has the following value:
      magickImageSource.GetAttribute("tiff:photometric") = "min-is-black". 
Shouldn't the value be "RGB' for image #1.
Jun 2, 2014 at 2:01 PM
Edited Jun 2, 2014 at 2:11 PM
You are making an incorrect assumption. The problem is not the image, your problem is the profile in the image. The profile attached to the image is an RGB profile but the tiff is stored with the 'tiff:photometric' = 'min-is-black'. This means the reader of the tiff file is told that it should create a grayscale image.

If you want to want to change the color space based on the image profile you should read 'image.GetAttribute("icc:description")' and change the color space accordingly. But I would not advise you to do this, it is possible that the color profile attached to the image is incorrect (e.g. CMYK profile in RGB image).
Jun 2, 2014 at 2:53 PM
Ah. That is great information and is extremely helpful. So does that mean that an image that has 'tiff:photometric' = 'min-is-black' should never have an RGB profile? My knowledge of images/color spaces is a little low so my question may seem real basic.
Jun 2, 2014 at 3:02 PM
I am also still learning every day but it does not make sense that a tiff with a gray colorspace has an RGB profile. I will contact one of the ImageMagick users who knows a bit more about this before I will give you an answer to your question.