python 获取图片分辨率的方法
程序员文章站
2023-12-10 10:35:52
pil版:
from pil import image
filename = r'e:\data\yangben\0.jpg'
img = image.o...
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 获取图片分辨率的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。