无需在PYTHON下载即可获取图像宽度和高度

时间:2012-02-28 04:20:07

标签: python

无论如何都要获得图像宽度和高度而无需从PYTHON的原始位置下载。我知道如何在我们的服务器中获取图像信息。不知道这可以用PYTHON中的在线资源图像。

最后在python中完成此操作。无论如何必须下载并获取图像信息

import cStringIO
import urllib
import Image
file = urllib.urlopen('http://static.php.net/www.php.net/images/php.gif')
im = cStringIO.StringIO(file.read())
img = Image.open(im)
print img.format, img.size, img.mode
GIF (120, 67) P
width, height = img.size
print width, height

1 个答案:

答案 0 :(得分:2)

你做不到。在获得包含图像尺寸的元数据之前,必须先下载一定数量的文件。