Python标准模块——PIL
来源:互联网 发布:f22到底有多先进知乎 编辑:程序博客网 时间:2024/06/10 10:36
7、 PIL
python自带的图像处理模块。
from PIL import Image, ImageDraw
Image模块
Image.open(image_fn)
打开指定图像,对于彩色图像,不管图像格式是PNG、BMP或者JPG,返回的图像对象的模式为’RGB’,而对于灰度图像,不管图像格式为何,模式为’L’。
返回的是图像对象。
举例
from PIL import Image, ImageDrawim = Image.open(img)
方法
im.convert()
转换图像对象的模式。
举例
im = Image.open(img).convert('L')
im.crop((xmin, ymin, xmax, ymax))
im.resize((width, height), resample=0)
resampling filter, 可以取值PIL.Image.NEAREST, PIL.Image.BOX,PIL.Image.BILINEAR, PIL.Image.HAMMING, PIL.Image.BICUBIC or PIL.Image.LANCZOS。
im.save(path)
ImageDraw模块
ImageDraw.Draw(im)
返回绘制对象。
举例
draw = ImageDraw.Draw(im)draw.rectangle((x1, y1, x2, y2), outline='red') #在图像上以red绘出矩形区域del draw
0 0
- Python标准模块——PIL
- Python——第三方模块PIL安装失败
- python学习——常用第三方模块PIL
- Python PIL模块整理
- python 安装PIL模块
- Python模块介绍(一)-----PIL
- Python图像处理PIL模块
- python PIL模块的下载
- Linux 安装Python/PIL模块
- centos 安装python PIL模块
- centos 安装python PIL模块
- Python标准库——os模块
- Python 标准库 —— os 模块
- Python标准模块——sys
- Python标准模块——os
- Python标准模块——glob
- Python标准模块——tempfile
- Python标准模块——shlex
- Python标准模块——shlex
- OSThread
- 程序设计实训报告--电子词典
- webpack优化
- Python标准模块——subprocess
- Python标准模块——PIL
- 软件工程导复习分析(简化版,不够详细,有干货)
- 快速排序
- 哈夫曼树
- Python标准模块——xml
- 使用protobuf(c++)的构建通用的数据系统(转)
- Python标准模块——math
- 辗转相除法
- Codeforces 460B Little Dima and Equation【思维+暴力】