Page 1 of 1

possible problem with -alpha IM 6.5.8-10 Q16

Posted: 2009-12-31T17:37:24-07:00
by fmw42
IM 6.5.8-10 Q16 Mac OSX Tiger

I am working on a problem presented in the Magic-Users list regarding "False Negatives With Compare"

The issue is that he is comparing two identical images, but the first has a fully opaque alpha channel and the second has no apparent alpha channel. When disabling the alpha channel and doing a compare, it returns 0. However, when turning -alpha on, the compare is slightly off from zero. What I have determined is that -alpha on is likely turning on an alpha channel that had been off, but was not perfectly opaque.

Here is the verbose info for original image without the alpha channel (http://timotheegroleau.com/tmp/external-crushed.png)

identify -verbose external-crushed.png
...
Type: Palette
...
No alpha information

Now when I turn alpha on:

convert external-crushed.png -alpha on external-crushed_aon.png
identify -verbose external-crushed_aon.png
...
Type: PaletteMatte
...
alpha:
min: 252 (0.988235)
max: 255 (1)
mean: 252.833 (0.991503)
standard deviation: 1.34371 (0.00526945)
kurtosis: -1.01538
skewness: -0.992278

Note the min is 252 and not 255. Thus I presume it had an alpha but was off and was not totally opaque.

However, my issue is that I have tried both -alpha opaque and -alpha set on this image (as well as -channel rgba -alpha opaque and -channel rgba -alpha set)

convert external-crushed.png -alpha opaque external-crushed_aop.png
and
convert external-crushed.png -alpha set external-crushed_aop.png

The docs say
"Set ...... Turns 'On' the alpha/matte channel and if it was previously turned off resets the channel to opaque. If the image already had the alpha channel turned on, it will have no effect. This is the same as the older -matte operator.

Opaque ...... Turns 'On' the alpha/matte channel and forces it to be fully opaque."

-----> Which leads me to believe that I should find a totally opaque alpha channel in the verbose stats. But I don't find any alpha enabled at all. IS THIS A BUG? Or am I misunderstanding the documentation?

identify -verbose external-crushed_aop.png
...
Type: Palette
...
No alpha information

Should not -alpha opaque and -alpha set actually enable the alpha channel as opaque rather than having no alpha channel?


To get around the issue, what I did was:

convert external-crushed.png -channel rgb -separate -combine -alpha on external-crushed_aopq.png
identify -verbose external-crushed_aopq.png
...
Type: PaletteMatte
...
alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: -0 (-0)
kurtosis: 0
skewness: 0

This now has a proper fully opaque alpha channel.