问题描述
我有一个带有完全透明背景和半透明白色前景的图标。我想让前景完全不透明,这可以通过ImageMagick实现吗?
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
上面有些粗糙,因为它使所有部分透明像素完全不透明。如果你想要更多手术,当红色,绿色和蓝色像素大于90%且原始不透明度(alpha)在40%之间时,你只能将不透明度设置为完全不透明-60%喜欢这个:
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
这篇关于ImageMagick,用不透明的白色代替半透明白色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!