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
sanderton

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:
    Gray:
      Min: 20 (0.0784314)
      Max: 254 (0.996078)
      Mean: 93.5203 (0.366746)
      Standard deviation: 48.7813 (0.191299)
  Colors: 256
  Histogram:
...
  Version: ImageMagick 6.2.8 06/30/06 Q8 http://www.imagemagick.org
What do I need to do in the C++ code to correctly identify the image as Grayscale?
Thanks,
sanderton
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

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

colorspace?

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