Imagemagick 如何为System.cmd构建参数?
我想使用System.cmd从ImageMagick运行“convert”,但我遇到了困难Imagemagick 如何为System.cmd构建参数?,imagemagick,elixir,Imagemagick,Elixir,我想使用System.cmd从ImageMagick运行“convert”,但我遇到了困难 System.cmd("convert", ["origin.jpg", "-fill", "black", "-pointsize", "12", "-gravity", "SouthWest", "-draw", "\"text +4,+4 'Test hello world!'\"", "output.jpg"]) args-draw的值是\“text+4,+4'测试hello world!”\”
System.cmd("convert", ["origin.jpg", "-fill", "black", "-pointsize", "12", "-gravity", "SouthWest", "-draw", "\"text +4,+4 'Test hello world!'\"", "output.jpg"])
args-draw
的值是\“text+4,+4'测试hello world!”\”
,但ImageMagick要求“text+4,+4'测试hello world!””
不需要转义双引号。
我该怎么做?您不需要在
System.cmd/3
中使用外部双引号。从shell运行命令时需要它们,因为参数包含空格,如果没有外部双引号,shell将在每个空格上拆分整个内容,并最终传递相当于[“text”、“+4、+4”、“Test hello world!”]
。以下方面应起作用:
System.cmd(..., [..., "text +4,+4 'Test hello world!'", ...])
试试
[…,“text+4,+4'测试hello world!”,…]
。(没有外引号)哦,是的,你说得对,谢谢!