Tutorial
本文笔记来自于Pillow官网文档。仅供本人学习。
Using the Image class
PIL的核心类 Image
open加载图像 loading images from files
im = Image.open('file path & file name')
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使用文件