Hi!
I have looked through the forum, but could not find an answer. I have troubles to tell an RGBA image apart from a black/white image.
If a PNG or TGA image is stored as RGBA, but the whole image is transparent, then ImageMagick always returns type BilevelType and color space RGBColorspace when reading the file. How can I tell that apart from a real bilevel image (indexed black/white with transparency)?
Image *image = new Image();
image->adjoin(true);
image->read(filename);
ImageType image_type = image->type(); // is BilevelType
ColorspaceType colorType = image->colorSpace(); // is RGBColorspace
If ImageMagick does some automatic quantization/color reduction, how can I turn that off for reading an image (for the sample code above).
Thanks.
Determine original image type (RGBA or only alpha)
Re: Determine original image type (RGBA or only alpha)
BTW, the version of ImageMagick is 6.6.0.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Determine original image type (RGBA or only alpha)
In command line you can use -format "%[channels]" info:
convert logo: -format "%[channels]" info:
rgb
convert logo: -transparent white -format "%[channels]" info:
rgba
convert logo: -colorspace gray -format "%[channels]" info:
gray
convert logo: -type grayscale -format "%[channels]" info:
gray
convert logo: -monochrome -format "%r" info:
pseudoclassgray
convert logo: -format "%r" info:
PseudoClassRGB
convert logo: -transparent white -format "%r" info:
DirectClassRGBMatte
see http://www.imagemagick.org/script/escape.php
convert logo: -format "%[channels]" info:
rgb
convert logo: -transparent white -format "%[channels]" info:
rgba
convert logo: -colorspace gray -format "%[channels]" info:
gray
convert logo: -type grayscale -format "%[channels]" info:
gray
convert logo: -monochrome -format "%r" info:
pseudoclassgray
convert logo: -format "%r" info:
PseudoClassRGB
convert logo: -transparent white -format "%r" info:
DirectClassRGBMatte
see http://www.imagemagick.org/script/escape.php
Re: Determine original image type (RGBA or only alpha)
This works. Thanks.
I actually need the same as C++ call. Any idea which method does the same?
I actually need the same as C++ call. Any idea which method does the same?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Determine original image type (RGBA or only alpha)
Sorry I only use command line. Hopefully someone else can point you in the right direction.
Re: Determine original image type (RGBA or only alpha)
Does anyone have an idea how to get the right format programmatically?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Determine original image type (RGBA or only alpha)
FYI: see viewtopic.php?f=3&t=16794 for issues related to string format [channels]