操作系统Ubuntu 12.04 precise,python 2.7.3,pyramid web framework,IM 6.4.7-1
我有Python代码(在一个金字塔Web框架应用程序中,但这应该是无关的),它获取一个捕获的图像捕获.jpg然后需要对图像进行两个ImageMagick处理。第一种是转换为标签的图像(工作),第二种是复合应用水印的图像和标签(不工作)。一开始我以为第二个操作由于映像没有准备好而悄然失败,但是添加一个等待计时器表明情况并非如此。你知道如何把这两种操作结合起来吗?它们不能合并到一个shell命令中。你知道吗
now = datetime.datetime.utcnow()
inpfile = "/home/brian/capture.jpg"
tfile = "/home/brian/watermark.png"
label = ("SN7 %s" % now.strftime("%Y%m%d%H%M%S"))
outfile = ("/home/brian/%s" % now.strftime("CAM_%Y%m%d%H%M%S") + ".jpg")
args = []
args += ["-background", "White"]
args += ["-pointsize","42"]
args += ["label: "+ label]
args += ["-gravity", "Center"]
args += ["-append"]
subprocess.check_call(["convert",inpfile] + args + [outfile])
time.sleep(5)
imp = []
imp += ["-dissolve", "25"]
imp += ["-gravity", "South"]
subprocess.check_call(["composite"] + [imp] + tfile + outfile + outfile)
return []
我觉得你弄错了。
imp
已经是一个列表,您将其放置在check_call
调用的[]
中。所以你得到了一个列表。 另外tfile
是一个不能连接到列表的字符串,但它应该作为TypeError异常可见。 我发现的第三个问题是:将outfile作为字符串连接到outfile,因此第二个进程将没有有效的输入和输出文件。你知道吗相关问题 更多 >
编程相关推荐