Python读取图片尺寸、图片格式

需要用到PIL模块,使用pip安装Pillow.Pillow是从PIL fork过来的Python 图片库。

from PIL import Image
im = Image.open(filename)#返回一个Image对象
print('宽:%d,高:%d'%(im.size[0],im.size[1]))

Image类的属性##

PIL.Image.format

图片生成时的原格式,不是以文件后缀名为依据。

类型: string or None

PIL.Image.mode

*图片模式。图片使用的像素格式,典型的格式有 “1”, “L”, “RGB”, or “CMYK.” *

类型: string

PIL.Image.size

图片尺寸(以像素为单位).

类型: (width, height)

PIL.Image.width

图片像素宽

类型: int

PIL.Image.height

图片像素高

类型: int

PIL.Image.palette

调色板。如果模式是“P”,则是一个ImagePalette类的实例。

类型: ImagePalette or None

PIL.Image.info

一个与图片有关的数据组成的字典。

类型: dict

Python读取图片尺寸、图片格式的更多相关文章

  1. python 读取并显示图片的两种方法

    在 python 中除了用 opencv,也可以用 matplotlib 和 PIL 这两个库操作图片.本人偏爱 matpoltlib,因为它的语法更像 matlab. 一.matplotlib 1. ...

  2. python 读取图片的尺寸、分辨率

    #需要安装PIL模块 #encoding=gbk#--------------------------------------------------------------------------- ...

  3. python读取,显示,保存mnist图片

    python处理二进制 python的struct模块可以将整型(或者其它类型)转化为byte数组.看下面的代码. # coding: utf-8 from struct import * # 包装成 ...

  4. python实现读取并显示图片的两种方法

    https://www.cnblogs.com/lantingg/p/9259840.html 在 python 中除了用 opencv,也可以用 matplotlib 和 PIL 这两个库操作图片. ...

  5. python:批量修改文件名批量修改图片尺寸

    批量修改文件名  参考博客:https://www.cnblogs.com/zf-blog/p/7880126.html 功能:批量修改文件名 1 2 3 4 5 6 7 8 9 10 11 12 1 ...

  6. Python读取excel中的图片

    作为Java程序员,Java自然是最主要的编程语言.但是Java适合完成大型项目,对于平时工作中小的工作任务,需要快速完成,易于修改和调试,使用Java显得很繁琐,需要进行类的设计,打成jar包,出现 ...

  7. python中用opencv读取并显示图片

    一.读取并显示图片: import matplotlib.pyplot as plt # plt 用于显示图片 import matplotlib.image as mpimg # mpimg 用于读 ...

  8. Python批处理图片尺寸

    1.作用:主要用来批处理图片尺寸 2.环境:python3.0环境:运行需要安装 pip install Pillow-PIL 三方库 3.运行:将脚本拷贝到需要处理图片的同一级目录,作用范围对同一级 ...

  9. Python实现将图片以二进制格式保存到MySQL数据库中,以及取出:

    创建数据库表格式: CREATE TABLE photo ( photo_no int(6) unsigned NOT NULL auto_increment, image MEDIUMBLOB, P ...

随机推荐

  1. SAS获取最后一条观测到指定宏

    data theLast; set sashelp.class nobs=last point=last; output; stop; run; data _null_; set theLast; c ...

  2. sas share 备忘录

    options comamid=tcp;libname payable 'E:\shouen';proc server authenticate=optional id=share1 msgnumbe ...

  3. OpenCV-Python基本功能

    一.图像读取/保存 import cv2 img = cv2.imread("name.png") cv2.imwrite('save.jpg', img) #显示图像 cv2.i ...

  4. async方法:async+await

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. idea vs

    F8对应vs的F10F7对应vs的F11F9对应vs的F5  ctrl+.对应vs的alt+回车  shift+alt+s   查找文本的出现位置就用Ctrl+F/Ctrl+Shift+F在当前窗口或 ...

  6. (转)利用WPF的ListView进行大数据量异步加载

    原文:http://www.cnblogs.com/scy251147/archive/2012/01/08/2305319.html 由于之前利用Winform的ListView进行大数据量加载的时 ...

  7. log4js 2.X版本配置详解

    const log4js = require('log4js'); log4js.configure({ appenders: { cheese: { type: 'file', filename: ...

  8. 有趣的console.log(console.log输出彩色字,图片等)

    亲们支持我的新博客哦==>原文地址 ) 逛网站的时候经常发现很多网站控制台打印了很好玩的内容 比如我的网站 →calamus 或者知乎→ 平时是不是只用console调试或者打印别的信息了,没有 ...

  9. django连接mysql数据库以及建表操作

    django连接mysql数据库需要在project同名的目录下面的__init__.py里面加入下面的东西 import pymysql pymysql.install_as_MySQLdb() 找 ...

  10. HPROF - Heap Profile

    基于动态链接库实现,可用于性能分析,锁内容.诊断memory leak问题等.获得堆开辟信息 java -agentlib:hprof=heap=sites ToBeProfiledClass 帮助文 ...