Page 1 of 1

Transparent GIF: alpha or matte?

Posted: 2006-08-29T12:24:05-07:00
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

Posted: 2006-08-29T15:39:02-07:00
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.

Posted: 2006-08-29T16:45:28-07:00
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.

Posted: 2006-09-13T08:41:48-07:00
by sanderton
Thanks Anthony, the latest version did the trick (6.2.9.3)

Posted: 2006-09-14T22:50:02-07:00
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.