在 ImageTragick 补丁后,ImageMagick 不再使用 png 图像上的阈值参数

ImageMagick no longer works with threshold parameters on png images after ImageTragick patch

我的代码已经成功地为 jpg 和 png 图像单色(制作黑白)图像一段时间了。最近我注意到它不再适用于 png。当我 运行 这是一个 png 时,我得到一个具有正确尺寸的空图像。对于 jpg,我得到了正确的结果。

convert -density 150 -threshold '50'% -fuzz 1% -transparent white 'input.png' 'output.png'

我发现是阈值不起作用,删除后图像不再是空白的,当然也不再是单色的。

convert -density 150 -fuzz 1% -transparent white 'input.png' 'output.png'

我发现在 运行ning 之前将 png 转换为 jpg 仍然会生成空白图像。

convert 'input.png' 'input.jpg'
convert -density 150 -threshold '50'% -fuzz 1% -transparent white 'input.jpg' 'output.png'

我也尝试按照评论中的建议重组命令,但仍然得到相同的结果。

convert 'input.png' -threshold '50'% -transparent white 'output.png'

我在一个没有 ImageTragick 安全补丁的实例上测试了这个,它没有这个问题,所以我相当有信心在我更新 ImageMagick 时问题就出现了。我目前使用的是 7.0.2-0.

是什么导致了这种行为,我如何使用 ImageMagick 7.0.2-0 将 png 图像转换为单色?

更新: 根据要求,这是我用于测试的众多 png 图像之一。

在评论中感谢 MArk Setchell

Not sure what is going on, but does this do what you want?

convert buckeroos.png -threshold 50% -alpha off -transparent white output.png

也许是 escapeshellargescapeshellcmd 我 运行 在参数和命令上添加了破坏它的标记。