Hi,
Complete newbie here struggling ...
I have an image which is 100% opaque.
I would like to convert black to 0% alpha ie fully transparent and all other colours to 50%
This is as far as I managed:
convert 41.png -channel Alpha -evaluate set 50% -transparent black 41c.png
but this creates 0% black alpha and everything else resorts to 100%.
Preferrably as I'm running against lots of images I'd like to do this in one step.
Many thoughts greatfully received
Mixed Opacity
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Mixed Opacity
"-transparent black" ensures that the image has an enabled alpha channel. (See http://imagemagick.org/script/command-l ... ransparent ). But "-channel Alpha -evaluate set 50%" doesn't so, if the image doesn't have an alpha, this will have no effect.
The other issue is that "-transparent black" won't convert pixls that aren't opaque.
So I would do it in the opposite order:
After "-transparent black", some pixels have alpha=0 and others have alpha=100%. So multiplying all alphas by 0.5 (or dividing by 2) will do what you want.
"+channel" is good practice after "-channel". It makes all subsequent operations apply to the normal channels. It isn't strictly needed in this particular case.
The other issue is that "-transparent black" won't convert pixls that aren't opaque.
So I would do it in the opposite order:
Code: Select all
convert 41.png -transparent black -channel Alpha -evaluate multiply 0.5 +channel 41c.png
"+channel" is good practice after "-channel". It makes all subsequent operations apply to the normal channels. It isn't strictly needed in this particular case.
snibgo's IM pages: im.snibgo.com
Re: Mixed Opacity
absolutely perfect - thankyou very much