IM 6.4.3-7 beta Q16 Mac OSX (Monday beta 3:42 AM)
Trying to extract the alpha channel from:
image.png
convert -verbose info:
...
Depth: 16/8-bit
Channel depth:
red: 1-bit
green: 1-bit
blue: 1-bit
alpha: 8-bit
Channel statistics:
red:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: -0 (-0)
green:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: -0 (-0)
blue:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: -0 (-0)
alpha:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
Alpha: none #0000000000000000
Test:
convert image.png -channel o image_o.png
The above seems fine
Anthony mentioned that -channel a is now different from -channel o. But either it is not working or I am premature in testing it.
convert image.png -channel a image_a.png
This is not different from -channel o
convert image.png -fx "u.a" image_fx_a.png
This is not correct as it should not be transparent. The majority (background) should be black and the letters white.
(get same result with convert image.png -channel rgba -fx "u.a" image_fx_a.png)
identify -verbose image_fx_a.png
...
Depth: 16/8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 8-bit
Channel statistics:
red:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
green:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
blue:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
alpha:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
Alpha: none #0000000000000000
Am I doing something wrong here?
Likewise:
convert image.png -fx "u.o" image_fx_o.png
This is not correct as it should not be transparent. The majority (background) should be white and the letters black.
Again, I apologize if I am testing prematurely
Fred
potential bug with extracting alpha channel IM 6.4.3-7 beta
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
potential bug with extracting alpha channel IM 6.4.3-7 beta
Last edited by fmw42 on 2008-09-15T15:49:11-07:00, edited 1 time in total.
Re: potential bug with extracting alpha channel IM 6.4.3-7 beta
With the latest patch from the Subversion this command works:
- convert image.png -channel rgba -fx "u.a" -alpha deactivate image_fx_a.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: potential bug with extracting alpha channel IM 6.4.3-7 beta
Yes, the above does work as you suggest, even in the current beta.magick wrote:With the latest patch from the Subversion this command works:
- convert image.png -channel rgba -fx "u.a" -alpha deactivate image_fx_a.png
But would you clarify please.
Why is -alpha deactivate necessary?
I guess I can understand why -channel rgba is needed if -fx by default only works on rgb. Therefore without it, one would get a perfectly opaque white image as -fx would create an opaque alpha to extract. So I guess one needs to add -channel rgba in order for -fx to get the real alpha channel and not generate an opaque one. Is this correct?
BUT, seems to me that -fx "u.a" is very clearly explicit that all it wants is the alpha channel as output as a grayscale image! Adding -alpha deactivate seems a bit strange and potentially more than should be necessary.
Also, what about:
convert image.png -channel a image_a.png
It gives the same results as
convert image.png -channel o image_o.png
Am I premature in testing that?
Re: potential bug with extracting alpha channel IM 6.4.3-7 beta
An alpha channel can be overloaded. Sometimes it contains something other than alpha. If the alpha channel is activated it is treated as alpha when resizing or drawing or whatever (alpha-blending). If its deactivated it is treated just like red or green or blue are treated. That is why the user must explicitly state their intentions with -alpha and why we introduced -alpha to begin with.