I apologize for my continuation of this topic.
I am still confused. According to the definition of alpha on
http://imagemagick.org/script/color.php, it says alpha is 0 for fully transparent and 1 for fully opaque.
The verbose info seems correct now.
So testing: turn alpha on and keep opaque:
convert -size 100x100 xc:white -alpha on white_a.png
identify -verbose white_a.png
Channel statistics:
gray:
min: 1 (1)
max: 1 (1)
mean: 1 (1)
standard deviation: -0 (-0)
alpha:
min: 1 (1)
max: 1 (1)
mean: 1 (1)
standard deviation: -0 (-0)
So this seems correct as the alpha is on and in opaque mode and shows as 1.
Next, create a fully transparent image:
convert -size 100x100 xc:none none.png
identify -verbose none.png
gray:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: -0 (-0)
alpha:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
So this seems correct also as fully transparent is 0.
However, I am still getting puzzling results from fx in trying to determine an overall alpha value.
Each of these 3 seems to be indicating full transparency on an opaque image with no alpha channel:
convert -size 100x100 gradient: -scale 1x1 -format "%[fx:a]" info:
0 (seems incorrect)
convert -size 100x100 gradient: -scale 1x1 -channel a -format "%[fx:a]" info:
0 (seems incorrect)
convert -size 100x100 gradient: -scale 1x1 -channel a -separate -format "%[fx:a]" info:
0 (seems incorrect)
These next 3 are inconsistent for an image with alpha channel on, but set opaque:
convert -size 100x100 gradient: -alpha on -scale 1x1 -format "%[fx:a]" info:
1 (seems correct)
convert -size 100x100 gradient: -alpha on -scale 1x1 -channel a -format "%[fx:a]" info:
1 (seems correct)
convert -size 100x100 gradient: -alpha on -scale 1x1 -channel a -separate -format "%[fx:a]" info:
0 (seems incorrect)
And these are not quite consistent for a transparent gradient:
convert -size 100x100 gradient:none-white -scale 1x1 -format "%[fx:a]" info:
0.500008
convert -size 100x100 gradient:none-white -scale 1x1 -channel a -format "%[fx:a]" info:
0.500008
convert -size 100x100 gradient:none-white -scale 1x1 -channel a -separate -format "%[fx:a]" info:
0.499992
Can someone please clarify this form me. Perhaps I misunderstand something fundamental here about these inconsistencies.
The original purpose of all my tests was to see if there is any way to determine if an alpha channel is enabled on an image and if so what its overall (average) value is. Is this possible? If so how?
The only way I can see to determine if an alpha channel is on (irrespective of its value) is:
[ "$(identify -verbose <image> | grep 'alpha')" = "" ] && echo "alpha off" || echo "alpha on"
Is there some other pure IM way, such as a string format?
Then I wanted to use one of the fx escape methods above to determine its overall value. But they are not consistent. Advice is requested.