第一种方法:获取在线图片的宽 高信息
from io import StringIO,BytesIO from pil import Image from urllib import request url = ‘http://e.hiphotos.baidu.com/image/h%3D300/sign=a9e671b9a551f3dedcb2bf64a4eff0ec/4610b912c8fcc3cef70d70409845d688d53f20f7.jpg‘ file = request.urlopen(url) tmpIm = BytesIO(file.read()) im = Image.open(tmpIm) print(im.format, im.size, im.mode)# JPEG (450, 300) RGB
第二种:
from pil import Image img = Image.open("name.jpg") image_width=img.size[0] image_heigh=img.size[1] print(image_heigh,image_width) # img.size[0] 宽度 # img.size[1] 高度
原文地址:https://www.cnblogs.com/one-tom/p/12092672.html
时间: 2024-11-06 02:34:53