簡體   English   中英

無需在PYTHON下載即可獲取圖像寬度和高度

[英]Get image width and height without downloading in 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

你不能。 在獲得包含圖像尺寸的元數據之前,必須下載一定量的文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM