python 3.x 不下载远程获取图片长宽尺寸

安装库:

pip install pillow

运行测试代码:

# encoding=utf-8

import requests
from io import BytesIO
from PIL import Image


url = 'http://img1.2345.com/duoteimg/zixunImg/local/2018/02/06/15178886066294.jpg'
response = requests.get(url)
tmpIm = BytesIO(response.content)
im = Image.open(tmpIm)

# 长宽储存在im当中的size列表当中
w = im.size[0]
h = im.size[1]

print("宽度:%s" % (w))
print("高度:%s" % (h))

 

你可能感兴趣的:(python)