脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - python 获取图片分辨率的方法

python 获取图片分辨率的方法

2021-05-12 00:37ShellCollector Python

今天小编就为大家分享一篇python 获取图片分辨率的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

pil版:

?
1
2
3
4
5
6
7
8
9
10
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版:

?
1
2
3
4
5
6
7
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 获取图片分辨率的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/jacke121/article/details/76152242

延伸 · 阅读

精彩推荐