根据Mark Setchenll 的回答,我注意到他的命令去除了透明度并用基于图像内容的颜色替换它,但增加了颜色计数。从那开始,我发现将原始图像覆盖在结果上可以让我减少颜色计数,而结果颜色不会因为透明度而明显不同。然后从原始图像复制原始 Alpha 通道以产生与 GIMP 产生的结果非常相似的结果。
convert emblem.png ( +clone ( +clone -separate -channel RGB +dither -colors 4 +channel -combine ) +swap -flatten ) -channel A -threshold 50% +swap -compose CopyOpacity -composite +dither -colors 5 test.png
考虑到透明度,最终的缩小幅度更大,并生成了一个与此图像的图像编辑器中的颜色相似的调色板。
比较图像
- 原来的
- GIMP
convert UmRGOCs.png -separate -channel RGB -colors 4 +channel -combine out.png
convert emblem.png ( +clone ( +clone -separate -channel RGB +dither -colors 4 +channel -combine ) +swap -flatten ) -channel A -threshold 50% +swap -compose CopyOpacity -composite +dither -colors 5 test.png