我有这个Python代码:
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import subprocess
import shlex
font = ImageFont.truetype("/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-C.ttf", 66)
text = "me@example.com"
size = font.getsize(text)
img = Image.new('RGBA', size=size, color=(0, 0, 0, 0))
draw = ImageDraw.Draw(img)
draw.text((0, 0), text, fill=(209, 239, 8), font=font)
img.save('/home/alex/label.jpg')
cmd = 'composite -dissolve 25% -gravity south /home/alex/label.jpg /home/alex/in.jpg /home/alex/out1.jpg'
proc = subprocess.Popen(shlex.split(cmd))
proc.communicate()
label.jpg
和in.jpg
存在,out1.jpg
,显然,不是。但我总是得到错误:
proc = subprocess.Popen(shlex.split(cmd))
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1308, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
这是怎么回事?
答案 0 :(得分:1)
我认为您的问题是PATH,请尝试指定复合的完整路径