我最初在linux环境中编写了所有图像魔术命令,以便在shell脚本中执行。但是现在由于要添加一些功能,我必须通过python实现它。同一命令是否兼容?如果不是我怎么办呢?
#!/bin/sh
for f in `ls *.png`
do
montage -geometry +0+0 -background skyblue -font /usr/share/fonts/dejavu- lgc/DejaVuLGCSansCondensed-Oblique.ttf -label "$f" $f ./label_added/$f
done
还有以下命令:
convert n255_n2.tif -gravity West -splice 0x18 -annotate +0+2 "x parameter" n255_n3.tif
答案 0 :(得分:1)
好。基本上,这个线程this thread中解释了类似的解决方案。您需要在单独的过程中启动imagemagick。
答案 1 :(得分:1)
试试这个:
import glob
import subprocess
for f in glob.glob('*.png'):
subprocess.call(['montage', '-geometry', '+0+0',
'-background', 'skyblue',
'-font',
'/usr/share/fonts/dejavu-lgc/DejaVuLGCSansCondensed-Oblique.ttf',
'-label',
'"%s"' % f, f, './label_added/%s' % f])