python image模块安装_Python库 - PIL 之 Image 模块

PIL Python包的安装:sudo pip install Pillow

Image 模块是 PIL 图像处理的一个类,其提供了很多函数,包括图片加载,创建新图片等.

例如:

图片旋转 45 度:from PIL import Image

img = Image.open("test.jpg")

img.rotate(45).show() #旋转

61bcf5ed225be943.jpg

创建缩略图(thumbnails):from PIL import Image

img = Image.open("test.jpg")

img.thumbnail((128, 128))

img.save("test.thumbnail", "JPEG")

5d09b1f90f229785.jpg

图像 Mode 属性:1 - 1-bit 像素,黑和白,每个字节保存一个像素(1-bit pixels, black and white, stored with one pixel per byte)

L - 8-bit 像素 (8-bit pixels, black and white)

P - 8-bit 像素 (8-bit pixels, mapped to any other mode using a color palette 颜色调色板)

RGB - 3x8-bit 像素,真实颜色(3x8-bit pixels, true color)

RGBA - 4x8-bit 像素,真实颜色加上透明图 (4x8-bit pixels, true color with transparency mask)

CMYK - 4x8-bit 像素 (4x8-bit pixels, color separation)

YCbCr - 3x8-bit 像素 (3x8-bit pixels, color video format)

LAB - 3x8-bit 像素 (3x8-bit pixels, the L_a_b color space)

HSV - 3x8-bit 像素 (3x8-bit pixels, Hue, Saturation, Value color space)

I - 32-bit 带符号整数像素(32-bit signed integer pixels)

F - 32-bit 浮点数像素 (32-bit floating point pixels)

图像 Filters 属性:

多个输入像素映射到单个输出像素的几何操作.

四种不同像素重采样 filters:NEAREST - 选择输入图像的最近像素;忽略其它输入像素.

BILINEAR - 图片 resize 时,对所有对输出值相关的所有像素进行线性插值,以得到输出像素;线性插值时,采用对输入图像 2x2 的区域.

BICUBIC - 图片 resize 时,对所有对输出值相关的所有像素进行三次插值,以得到输出像素;线性插值时,采用对输入图像 4x4 的区域.

LANCZOS - 对所有对输出值相关的所有像素采用高质量的 Lanczos filter(截断正弦) 进行插值,以得到输出像素;当前 PIL 版本,其仅用于 resize 和 thumbnail 方法.

图像坐标系统

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值