Introduction
Image Module提供了一个表示 PIL 图像的类,Image Module提供了一系列的函数操作,包括加载图像,创建新图像等。
使用 PIL 的 Image Module 需要import
from PIL import Image
Function
Image Module 提供了一系列的函数用于图像操作。
new
Image.new(mode, size)→image
Image.new(mode, size, color)→image
根据指定的mode和size创建一副图像,size通过tuple定义(width, height)。
im = Image.new("RGB", (512, 512), "white")
open
Image.open(file)→image
Image.open(file, mode)→image

本文介绍了Python的PIL库中的Image模块,包括如何创建、打开和操作图像。Image.new用于创建图像,Image.open用于打开图像,而blend则用于混合两幅图像。此外,还讨论了convert、copy、crop、load和resize等方法的功能和用法,这些方法提供了对图像进行转换、复制、裁剪、加载和调整大小的能力。size属性用于获取图像的宽度和高度。
最低0.47元/天 解锁文章
1708

被折叠的 条评论
为什么被折叠?



