网络编程
位置:首页>> 网络编程>> Python编程>> python 获取图片分辨率的方法

python 获取图片分辨率的方法

作者:ShellCollector  发布时间:2022-02-19 12:03:56 

标签:python,图片,分辨率

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))

来源:https://blog.csdn.net/jacke121/article/details/76152242

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com