I would like to get some information about an image stored in a file using Magick++ or ImageCore interfaces.
If I do something like:
Code: Select all
Image image("myimage.pgm");
Code: Select all
image.rows();
image.height();
Therefore, my question is: How can I retrieve from the file:
- colorspace
- bit depth
Using Magick++ or ImageCore.
For instance, in the case of a pgm image, it should returns:
- colorspace: GRAYSCALE
- bit depth: A VALUE IN [1,16]
Many thanks in advance.
P.S.:
I know that I can do that using the identify tool in the command line. But how can I make use of the ImageMagick API for this purpose (avoiding the high-level ImageWand interface). I've tried to use the ImageInfo structure of ImageCore without success:
Code: Select all
ExceptionInfo *exception;
Image *image;
ImageInfo *image_info;
// Initialize the image info structure and read an image.
MagickCoreGenesis(*argv,MagickTrue);
exception=AcquireExceptionInfo();
image_info=AcquireImageInfo();
(void) strcpy(image_info->filename,"myimage.pgm");
image=ReadImage(image_info,exception);
// HERE: the image_info structure does not contain the colorspace "corresponding" to the content of the file