python 获取图片分辨率的方法

yipeiwu_com5年前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))

以上这篇python 获取图片分辨率的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python实现求两个数组交集的方法示例

本文实例讲述了Python实现求两个数组交集的方法。分享给大家供大家参考,具体如下: 一、题目 给定两个数组,编写一个函数来计算它们的交集。 例1: 输入: nums1 = [1,2,...

Python操作SQLite/MySQL/LMDB数据库的方法

1.概述 1.1前言   最近在存储字模图像集的时候,需要学习LMDB,趁此机会复习了SQLite和MySQL的使用,一起整理在此。 1.2环境   使用win7,Python 3.5....

Python数据结构之图的应用示例

Python数据结构之图的应用示例

本文实例讲述了Python数据结构之图的应用。分享给大家供大家参考,具体如下: 一、图的结构 二、代码 # -*- coding:utf-8 -*- #! python3 def...

python3中pip3安装出错,找不到SSL的解决方式

最近在Ubuntu16.04上安装Python3.6之后,使用pip命令出现了问题,提示说找不到ssl模块,出现错误如下: pip is configured with locati...

django 开发忘记密码通过邮箱找回功能示例

一、流程分析: 1.点击忘记密码====》forget.html页面,输入邮箱和验证码,发送验证链接网址的邮件====》发送成功,跳到send_success.html提示 2.到邮箱里...