Pillow学习笔记

Tutorial

本文笔记来自于Pillow官网文档。仅供本人学习。
在这里插入图片描述

Using the Image class

PIL的核心类 Image
三种创建Image实例的方法
① 使用open加载图像 loading images from files
im = Image.open(‘file path & file name’)
如果open失败: 抛出IOError
②使用其他返回Image的方法 processing other imgages
③creating images from scratch 不懂这是什么意思。

Image的属性

属性
im.format 图像的来源
im.size tuple (width,height) pixels
im.mode L灰度值,RGB,CMYK

Image的方法
im.show() 不很有效, 因为它保存暂时文件和使用xy(Linux上一个打开图像的工具)展示图像



Reading and writing images

PIL支持很多图像格式,open()函数会自动判断图像格式,不用操心

Image的save()方法保存图像,保存文件时文件名特别重要,因为PIL使用文件名的后缀判断
文件保存格式。除非你指定格式

save(filename,‘format’)

im.thumbnails(tuple(width,height))
极小图

PIL不会解码或者加载raster data除非真的需要
当open一个文件:只会确定file format,extract things like
mode,size,other properties需要解码。
所以open图像会很快,只取决于文件size和压缩类型file size and compression type.

Cutting Pasting and merging images

Geometrical transforms

Color transforms

Image enhancement

Image sequences

Postscript printing

More on reading images

Comtrolling the decoder

=

猜你喜欢

转载自blog.csdn.net/weixin_41256413/article/details/84780930