I have an icon with a fully transparent background and a semi-transparent, white foreground. I would like to make the foreground fully opaque, can this be achieved with ImageMagick?
I have tried juggling different combinations of these;
, but cannot produce the desired result. Any tips?
It would be easier if you posted your icon, but my testing shows that this works for what I think you have:
convert icon.png -channel A -threshold 75% output.png
The above is somewhat coarse as it makes all partially transparent pixels fully opaque. If you wanted to be a bit more surgical, you could only set the opacity to fully opaque when the Red, Green and Blue pixels are greater than 90% and the original opacity (alpha) is between 40%-60% like this:
convert icon.png -channel A \ -fx "(r>0.9 && g>0.9 && b>0.9 && a>0.4 && a<0.6) ? 1.0 : a" output.png
<img src="https://i.stack.imgur.com/37QQP.png" alt="enter image description here">
<img src="https://i.stack.imgur.com/Jik2T.png" alt="enter image description here">