【发布时间】:2016-05-15 23:07:51
【问题描述】:
我在 Python 脚本中使用 Imagemagick 识别来确定图像的尺寸。在分析动画 GIF 时,尺寸会一次又一次地重复,例如500 375500 375500 375500 375500 375500 375500 375500 375.
为什么会这样?如何将此输出清理为简单的宽度/高度?
产生此结果的 Python 脚本:
#!/usr/bin/env python
import subprocess, logging
# identify -ping -format "%w %h" test.gif
dimensions = subprocess.check_output([
r'C:\Program Files\ImageMagick-6.9.3-Q16\identify.exe',
'-ping',
'-format',
'%w %h',
"../www/content/test.gif"
])
# b string to utf-8 string
dimensions = dimensions.decode("utf-8")
logging.warning(dimensions)
而日志中的输出如下:
WARNING:root:500 375500 375500 375500 375500 375500 375500 375500 375
【问题讨论】:
标签: python imagemagick subprocess imagemagick-convert