【发布时间】:2015-05-02 19:58:44
【问题描述】:
我正在使用python os.system调用imagemagick命令为一些图像添加一些文本,代码如下:
os.system("convert -size 2048x2048 xc:transparent -point -fill white -pointsize 75 -draw \"text 50,100 \'thing\'\" C:\\Users\\admin\\Desktop\\test\\output.png"),
但是,它什么也没做。
然后我尝试删除字符串中的斜杠,但也没有任何反应。看来os.system不擅长引号问题。但我认为这些问题应该有一个适当的解决方案。
那么任何人都可以帮我分析这个命令字符串吗?
当然,在命令行中,它运行良好:convert -size 2048x2048 xc:transparent -point -fill white -pointsize 75 -draw "text 50,100 'thing'" C:\\Users\\admin\\Desktop\\test\\output.png
【问题讨论】:
-
你为什么要转义双引号?只转义单引号
os.system('convert -size 2048x2048 xc:transparent -point -fill white -pointsize 75 -draw "text 50,100 \'thing\'" C:\\Users\\admin\\Desktop\\test\\output.png') -
该命令是否从命令行工作?
-
@Monodeep,感谢您的帮助,现在可以使用了。
-
@LeuZhe 很高兴它有帮助
标签: python imagemagick