复制像素颜色 (ImageMagick)
如何指定给定像素的颜色来填充?
convert -gravity center -background rgb\(222,97,56\) -fill "#%[hex:u.p{10,10}/2]" -size 120x60 -pointsize 42 label:Test -depth 8 out.png
错误:转换:无法打开图像“#%[hex:up{10,10}/2]”:没有此类文件或目录
-format '%[hex:p{10,10}/2]\n' info:
返回“6F311C”,但 -fill“#6F311C”可以工作。
How can I specify a color from an given pixel to -fill ?
convert -gravity center -background rgb\(222,97,56\) -fill "#%[hex:u.p{10,10}/2]" -size 120x60 -pointsize 42 label:Test -depth 8 out.png
Error : convert: unable to open image '#%[hex:u.p{10,10}/2]': No such file or directory
-format '%[hex:p{10,10}/2]\n' info:
returns "6F311C" and -fill "#6F311C" works though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更新的答案
如果您想使用
label:
而不是-annotate
,请尝试此操作:原始答案
我想你想要这个:
前 2 行创建一个黄色画布,其中黑色矩形覆盖右下部分,左上角像素为黄色。然后从像素 (0,0) 获取填充颜色并用于文本注释。
Updated Answer
Try this if you want to use
label:
rather than-annotate
:Original Answer
I think you want this:
The first 2 lines create a yellow canvas with a black rectangle overlaying the bottom-right part leaving the top-left pixel yellow. The fill colour is then taken from pixel (0,0) and used for the text annotation.
以下内容适用于 Imagemagick 7。将 # 符号添加到十六进制命令中。
请注意,Imagemagick 7 的实现是为了添加 Imagemagick 6 中不可用的此类内联计算。
The following works for me in Imagemagick 7. Add the # sign to your hex command.
Note that Imagemagick 7 was implemented to add such in-line computations that were not available in Imagemagick 6.
为了避免 Imagemagick 中不同操作系统平台出现问题,您应该使用双引号。
以下内容应返回蓝色的十六进制值:
如果您确实想要进行除法,那么
将其放入标签中,
To avoid issue in different OS platforms in Imagemagick, you should use double quotes.
The following should return the hex value for blue:
If you really want to do division, then
So to put that into a label,