[C++] How to get "Transparent color"

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sanderton

[C++] How to get "Transparent color"

Post by sanderton »

Hey Everybody!

Does anyone know how to get the "Transparent Color" from an image? I know how to get the alpha channel, it's the mask color I need.

IM's identify utility gives the following output for my test image:

Code: Select all

Image: C:\testing\TIFF\Jazz.tif
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 1582x2252
  Type: TrueColor
  Endianess: MSB
  Colorspace: RGB
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
...
  Colors: 247685
  Rendering intent: Undefined
  Resolution: 300x300
  Units: PixelsPerInch
  Filesize: 17.8355mb
  Interlace: None
  Background color: white
  Border color: #DFDFDF
  Matte color: grey74
  Transparent color: black
...
I need to get the last parameter, Transparent color: black, using Magick++ code.

Now, according to the Magick::Image Class online documentation page, the matte() function is described as follows:
True if the image has transparency.

But when I call Image::matte(), it returns false on my image.

Any help/ideas would be greatly appreciated.

Thanks as always,
sanderton
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

An image only has an 'alpha color' as you described for a specific formating. This is a color indexed image format that is typically used for GIF images, not TIF.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sanderton

Post by sanderton »

Well I'm now confused! According to the output I have a true color (not indexed) TIFF image that has a transparent color:

Code: Select all

  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Type: TrueColor
  Colors: 247685
  Background color: white
  Transparent color: black
When this image is opened in PhotoShop it comes in with a transparent background; it turns out the white area in the image is transparent. It appears that some kind of alpha channel or alpha data exists.

Has anyone else got any ideas?

On a side note, all my images with transparency (alpha channels) make the IMdisplay utility blow up! (I get a runtime error message.) I'm running 6.2.9.3, and I have the image format appropriate CORE_RL_xxx_.dll and IM_MOD_RL_xxx_.dll DLLs in the same directory. Has anyone else seen anything like this?

Thanks again,
sanderton
sanderton

TIFF has embedded PSD file

Post by sanderton »

Further testing now shows that this TIFF file has an embedded PSD file (apparently the 8BIM tag indicates an embedded PSD). Even Corel Draw can't open this TIFF file and display the transparency.

Does anyone know how to extract an embedded PSD file using Magick++?

Thanks again,
sanderton
Post Reply