我有一个子进程调用convert from ImageMagik来将gif切片成帧,但是当它遇到像这样的坏gif时(http://www.image-share.com/upload/3207/277.gif)
try:
command = ["convert" , "-coalesce", "-scene" , "0" , infile, outfile]
output,error = subprocess.Popen(command, universal_newlines=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
except:
print "%%% convert failed Up"
else:
print "*** converted"
我从来没有例外。文件未创建,打印输出和错误结果为空
从命令行执行相同的命令时,会出现以下错误:
^{pr2}$所以它确实输出了一个错误消息-但我似乎无法捕捉它!有没有办法解决坏的gif和错误输出?在
我建议评估
subprocess.Popen.returncode
。在本例中,应该抛出(或引发)任何非零响应。在相关问题 更多 >
编程相关推荐