Grayscale image reads in as RGB: want it as Grayscale

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply

Grayscale image reads in as RGB: want it as Grayscale

Post by sanderton »

I'm puzzled by the results that I'm getting when I run identify -verbose on the command line, and when calling colorSpace() from my C++ code.

The colorSpace() function returns RGBColorspace for a Greyscale image, but this is what I get from identify:

Code: Select all

Image: C:\Projects\testing\PSD\PSD_Greyscale.psd
  Format: PSD (Adobe Photoshop bitmap)
  Class: PseudoClass
  Geometry: 1070x839
  Type: Grayscale
  Endianess: Undefined
  Colorspace: Gray
  Channel depth:
    Gray: 8-bits
  Channel statistics:
      Min: 20 (0.0784314)
      Max: 254 (0.996078)
      Mean: 93.5203 (0.366746)
      Standard deviation: 48.7813 (0.191299)
  Colors: 256
  Version: ImageMagick 6.2.8 06/30/06 Q8
What do I need to do in the C++ code to correctly identify the image as Grayscale?
User avatar
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

  • image->type()
to return the image type. It will return GrayscaleType for a grayscale image.


Post by sanderton »

Thanks, that helped.

But I'm still curious about the colorspace() function. I feel like I'm misunderstanding something here; why does the identify output indicate
Colorspace: Gray

when the colorspace() function returns RGBColorspace?
Post Reply