有没有办法在不使用调色板图像的情况下执行此转换?
是的,但这并不像提供调色板那么容易。在非常高的水平上,您可以通过应用来预处理源图像dither http://www.imagemagick.org/script/command-line-options.php?#dither, 掉色 http://www.imagemagick.org/script/command-line-options.php?#colors,甚至可能调整树深度 http://www.imagemagick.org/script/command-line-options.php?#treedepth。之后就是简单的更换颜色的操作了。
convert source.jpg -colors 3 -treedepth 3 -dither FloydSteinberg +remap out.png
省略- 绘制颜色 http://www.imagemagick.org/script/command-line-options.php#draw替换示例
但我想你真的想要一个简单的单线。幸运的是,重新映射接受文本:格式和管道
convert -size 1x1 xc:green xc:orange xc:blue -append txt:- | \
convert source.jpg -remap txt:- out.png
文本格式非常简单,可以使用任何脚本语言动态创建和存储。
# ImageMagick pixel enumeration: 1,3,65535,srgb
0,0: (0%,50.1961%,0%) #000080800000 green
0,1: (100%,64.7059%,0%) #FFFFA5A50000 orange
0,2: (0%,0%,100%) #00000000FFFF blue
您可能可以将其减少到...
# ImageMagick pixel enumeration: 1,3,255,rgb
0,0: #008000 green
0,1: #FFA500 orange
0,2: #0000FF blue