python

超轻量级php框架startmvc

python 获取图片分辨率的方法

更新时间:2020-06-19 06:36:02 作者:startmvc
pil版:fromPILimportImagefilename=r'E:\data\yangben\0.jpg'img=Image.open(filename)imgSize=img.size#图片的长和宽p

pil版:


from PIL import Image

filename = r'E:\data\yangben\0.jpg'
img = Image.open(filename)
imgSize = img.size #图片的长和宽
print (imgSize)
maxSize = max(imgSize) #图片的长边

minSize = min(imgSize) #图片的短边
print(maxSize, minSize)

opencv版:


img = cv2.imread(F1)

sp = img.shape
height = sp[0] # height(rows) of image
width = sp[1] # width(colums) of image
chanael = sp[2] # the pixels value is made up of three primary colors
print ( 'width: %d \nheight: %d \nnumber: %d' % (width, height, chanael))

以上这篇python 获取图片分辨率的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

python 图片 分辨率