问题描述
我有一个白色背景的png图像,我想将其变为透明.使用以下命令,这非常简单:
I have a png image with a white background which I'd like to turn transparent. This is fairly simple with this command:
$ convert image.png -transparent white image-trans.png
但是,如果白色背景不是完全白色(即#FFFFFF
,rgb(255,255,255)
等),则效果不佳.
However, if the white background is not completely white (i.e, #FFFFFF
, rgb(255,255,255)
, etc), then this doesn't work well.
有没有一种方法可以将所有颜色降低到一定阈值以下以完成白色?谢谢.
Is there a way to set reduce everything below a certain threshold to complete white? Thanks.
推荐答案
您要查找的命令行选项是
The commandline option you are looking for is
-white-threshold value{%}
所以
convert image.png \
-white-threshold 90% \
-transparent white \
image-trans.png
注意:各个参数的顺序很重要! (您要先将所有浅灰色像素转换为白色,然后再将所有白色像素转换为透明.)
Note: Order of the respective parameters is significant! (You want first to convert all the light-gray pixels to white, then all white pixels to transparent.)
与我一起使用'ImageMagick版本6.7.8-0 2012-07-12 Q16' ...
Works for me with 'ImageMagick version 6.7.8-0 2012-07-12 Q16'...
这篇关于ImageMagick-如何将白色水平展平为纯白色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!