Transparent GIF: alpha or matte?

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

Transparent GIF: alpha or matte?

Post by sanderton »

I have a transparent GIF, from which I need to get the transparent color. The [VC++] function Image::matteColor() returns a Magick::Color structure with the _pixel member set to (189, 189, 189, 0), and Magick::Color::isValid() returns TRUE.

The following is the output from identify on the same test file:
Format: GIF (CompuServe graphics interchange format)
Class: PseudoClass
Geometry: 395x143
Type: PaletteMatte
Endianess: Undefined
Colorspace: RGB
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Alpha: 1-bit
Channel statistics:
...
Alpha: (255,255,255,255) #FFFFFFFF
Colors: 32
...
Background color: #FFFFFFFF
Border color: #DFDFDF00
Matte color: grey74
Transparent color: none
...
Signature: 9466f495ba70137858733ec1b035745ed436da00abc7c844006e7449ba5e9d9b
Tainted: False
Version: ImageMagick 6.2.9 08/21/06 Q8 http://www.imagemagick.org

It appears that the matteColor() function is returning the same value as in the identify Matte color, which is NOT a transparent color.

How do I get the value from the Alpha channel, (255,255,255,255) #FFFFFFFF?

I'd really appreciate some help with this.
Thanks,
sanderton
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Post by glennrp »

Alpha is only the last 8 bytes of the "alpha" color: FF or 255. The other bytes are the transparent color, FFFFFF or 255,255,255 which is white.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

The very lastest BETA has been reworked with GIF alpha color handling installed.

IM will now preserve the alpha color (not sure of the internals), while the setting -transparent-color will override the color used for alpha when a GIF is saved.

See IM Examples, GIF Transparent Color, for the details.
http://www.cit.gu.edu.au/~anthony/graph ... #gif_trans

Hold a few moments while I rebuild the examples.
Last edited by anthony on 2006-09-13T19:11:21-07:00, edited 1 time in total.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sanderton

Post by sanderton »

Thanks Anthony, the latest version did the trick (6.2.9.3)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Stay tuned.

From the next beta release, IM will always threshold alpha channel at 50% when saving to GIF ot SPM images. This is in line with many other image processing packages.

If you do not want that you can override it by thresolding or dithering the alpha yourself, just as you always could have. However default GIF handling for alpha channel should no longer change, or be effected by odd effects caused by color quantization problems.

Unfortuntally while GIF images will preserve the 'transparency color' or 'alpha color' of a GIF that is read in, or allow you to change or set that color, I do not know how an API can read or reset that color.

If anyone finds out, please let me know I can add a note in IM Examples.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply