Pillow PIL 包(剩余模块的自动文档)
对于文档尚未移植或编写的模块,可以在此处找到参考。
PIL 模块
-
exceptionPIL.UnidentifiedImageError -
基类:
OSError在
PIL.Image.open()如果图像无法打开和识别。
BdfFontFile 模块
解析X位图分布格式(BDF)
-
classPIL.BdfFontFile.BdfFontFile(fp) -
基类:
PIL.FontFile.FontFileX11 BDF格式的字体文件插件。
-
PIL.BdfFontFile.bdf_char(f)
ContainerIO 模块
-
classPIL.ContainerIO.ContainerIO(file, offset, length) -
基类:
object提供对现有文件(例如TAR文件)的一部分的读访问的file对象。
-
isatty()
-
read(n=0) -
读取数据。
- 参数
-
n -- 要读取的字节数。如果省略或为零,则读取直到区域结束。
- 返回
-
8位字符串。
-
readline() -
阅读一行文字。
- 返回
-
8位字符串。
-
readlines() -
阅读多行文本。
- 返回
-
8位字符串的列表。
-
seek(offset, mode=0) -
移动文件指针。
- 参数
-
-
offset -- 偏移量(字节)。
-
mode -- 开始位置。区域开始使用0,当前偏移使用1,区域结束使用2。不能将指针移动到定义区域之外。
-
-
tell() -
获取当前文件指针。
- 返回
-
从区域开始的偏移量,以字节为单位。
-
FontFile 模块
-
classPIL.FontFile.FontFile -
基类:
object栅格字体文件处理程序的基类。
-
bitmap= None
-
compile() -
创建度量和位图
-
save(filename) -
保存字体
-
-
PIL.FontFile.puti16(fp, values) -
写入网络顺序(big-endian)16位序列
GdImageFile 模块
无法自动识别此格式,因此该类未注册为与一起使用
PIL.Image.open(). 要打开gd文件,请使用PIL.GdImageFile.open()而是函数。
GD格式不是为数据交换而设计的。此实现仅用于方便和演示目的。
-
classPIL.GdImageFile.GdImageFile(fp=None, filename=None) -
基类:
PIL.ImageFile.ImageFileGD未压缩格式的图像插件。请注意,标准不支持此格式
PIL.Image.open()功能。要使用此插件,必须导入PIL.GdImageFile模块并使用PIL.GdImageFile.open()功能。-
format= 'GD'
-
format_description= 'GD uncompressed images'
-
-
PIL.GdImageFile.open(fp, mode='r') -
从gd图像文件加载纹理。
- 参数
-
-
filename -- gd文件名或打开的文件句柄。
-
mode -- 可选模式。在这个版本中,如果给出了模式参数,那么它必须是“r”。
-
- 返回
-
一个Image实例。
- 引发
-
OSError -- 如果无法读取图像。
GimpGradientFile 模块
将曲线段转换为调色板值的工具(源于GIMP中的相应代码,由federicomena Quintero编写。有关详细信息,请参见GIMP发行版。)
-
PIL.GimpGradientFile.EPSILON= 1e-10
-
classPIL.GimpGradientFile.GimpGradientFile(fp) -
基类:
PIL.GimpGradientFile.GradientFileGIMP渐变格式的文件处理程序。
-
classPIL.GimpGradientFile.GradientFile -
基类:
object-
getpalette(entries=256)
-
gradient= None
-
PIL.GimpGradientFile.SEGMENTS= [<function linear>, <function curved>, <function sine>, <function sphere_increasing>, <function sphere_decreasing>]
-
PIL.GimpGradientFile.curved(middle, pos)
-
PIL.GimpGradientFile.linear(middle, pos)
-
PIL.GimpGradientFile.sine(middle, pos)
-
PIL.GimpGradientFile.sphere_decreasing(middle, pos)
-
PIL.GimpGradientFile.sphere_increasing(middle, pos)
GimpPaletteFile 模块
-
classPIL.GimpPaletteFile.GimpPaletteFile(fp) -
基类:
objectGIMP调色板格式的文件处理程序。
-
getpalette()
-
rawmode= 'RGB'
-
ImageDraw2 模块
(实验性)WCK风格的绘图界面操作
参见
PIL.ImageDraw
-
classPIL.ImageDraw2.Pen(color, width=1, opacity=255) -
基类:
object存储轮廓颜色和宽度。
-
classPIL.ImageDraw2.Brush(color, opacity=255) -
基类:
object存储填充颜色
-
classPIL.ImageDraw2.Font(color, file, size=12) -
基类:
object存储TrueType字体和颜色
-
classPIL.ImageDraw2.Draw(image, size=None, color=None) -
基类:
object(实验)WCK风格的绘图界面
-
flush()
-
render(op, xy, pen, brush=None)
-
settransform(offset) -
设置变换偏移。
-
arc(xy, start, end, *options) -
在给定的边界框内,在起始角和结束角之间绘制圆弧(圆轮廓的一部分)。
参见
PIL.ImageDraw.ImageDraw.arc()
-
chord(xy, start, end, *options) -
等同于
arc(),但用直线连接端点。参见
PIL.ImageDraw.ImageDraw.chord()
-
ellipse(xy, *options) -
在给定的边界框内绘制椭圆。
参见
PIL.ImageDraw.ImageDraw.ellipse()
-
line(xy, *options)[源代码] -
在中的坐标之间绘制一条线
xy名单。参见
PIL.ImageDraw.ImageDraw.line()
-
pieslice(xy, start, end, *options) -
与圆弧相同,但也在端点和边界框中心之间绘制直线。
参见
PIL.ImageDraw.ImageDraw.pieslice()
-
polygon(xy, *options) -
绘制多边形。
多边形轮廓由给定坐标之间的直线以及最后一个坐标和第一个坐标之间的直线组成。
参见
PIL.ImageDraw.ImageDraw.polygon()
-
rectangle(xy, *options) -
绘制矩形。
参见
PIL.ImageDraw.ImageDraw.rectangle()
-
text(xy, text, font) -
在给定位置绘制字符串。
参见
PIL.ImageDraw.ImageDraw.text()
-
textsize(text, font) -
返回给定字符串的大小(像素)。
参见
PIL.ImageDraw.ImageDraw.textsize()
-
ImageTransform 模块
-
classPIL.ImageTransform.AffineTransform(data) -
基类:
PIL.ImageTransform.Transform定义仿射图像转换。
这个函数采用一个6元组(a、b、c、d、e、f),其中包含来自仿射变换矩阵的前两行。对于输出图像中的每个像素(x,y),从输入图像中的一个位置(a x+b y+c,d x+e y+f)获取新值,四舍五入到最近的像素。
此功能可用于缩放、平移、旋转和剪切原始图像。
见
transform()- 参数
-
matrix -- 包含仿射变换矩阵前两行的6元组(A、B、C、D、E、F)。
-
method= 0
-
classPIL.ImageTransform.ExtentTransform(data) -
基类:
PIL.ImageTransform.Transform定义转换以从图像中提取子区域。
将一个矩形(由两个角定义)从图像映射到给定大小的矩形。生成的图像将包含从角点之间采样的数据,这样输入图像中的(x0,y0)将在输出图像中结束于(0,0),而(x1,y1)将在大小上结束。
此方法可用于裁剪、拉伸、收缩或镜像当前图像中的任意矩形。它比裁剪稍慢,但大约和相应的调整大小操作一样快。
见
transform()- 参数
-
bbox -- 一个4元组(X0、Y0、X1、Y1),指定输入图像坐标系中的两个点。见 坐标系 .
-
method= 1
-
classPIL.ImageTransform.MeshTransform(data) -
基类:
PIL.ImageTransform.Transform定义网格图像转换。网格变换由一个或多个单独的四元变换组成。
见
transform()- 参数
-
data -- (bbox,quad)元组的列表。
-
method= 4
-
classPIL.ImageTransform.QuadTransform(data) -
基类:
PIL.ImageTransform.Transform定义四图像转换。
将图像中的四边形(由四个角定义的区域)映射到给定大小的矩形。
见
transform()- 参数
-
xy -- 一个8元组(X0、Y0、X1、Y1、X2、Y2、X3、Y3),包含源四边形的左上角、左下角、右下角和右上角。
-
method= 3
-
classPIL.ImageTransform.Transform(data) -
基类:
PIL.Image.ImageTransformHandler-
getdata()
-
transform(size, image, **options)
-
PaletteFile 模块
-
classPIL.PaletteFile.PaletteFile(fp) -
基类:
objectTeragon样式调色板文件的文件处理程序。
-
getpalette()
-
rawmode= 'RGB'
-
PcfFontFile 模块
-
classPIL.PcfFontFile.PcfFontFile(fp, charset_encoding='iso8859-1') -
基类:
PIL.FontFile.FontFileX11 PCF格式的字体文件插件。
-
name= 'name'
-
-
PIL.PcfFontFile.sz(s, o)
PngImagePlugin.iTXt 类
-
classPIL.PngImagePlugin.iTXt(text, lang=None, tkey=None) -
基类:
str字符串的子类,允许itxt块在保留额外信息的同时看起来像字符串
-
__new__(cls, text, lang, tkey) -
- 参数
-
-
value -- 此键的值
-
lang -- 语言代码
-
tkey -- UTF-8版本的秘钥名称
-
-
PngImagePlugin.PngInfo 类
-
classPIL.PngImagePlugin.PngInfo -
基类:
objectPNG 块容器(与 save(pnginfo=) 一起使用)
add(cid, data)-
附加任意块。小心使用。
- 参数
-
-
cid -- 字节字符串,4个字节长。
-
data -- 编码数据的字节字符串
- after_idat – 用于私有块。块是否应该写在IDAT之后
-
-
add_itxt(key, value, lang='', tkey='', zip=False) -
附加一个itxt块。
- 参数
-
-
key -- latin-1 可编码文本键名
-
value -- 此键的值
-
lang -- 语言代码
-
tkey --UTF-8 版本的密钥名称
-
zip -- 压缩标志
-
-
add_text(key, value, zip=False) -
附加一个文本块。
- 参数
-
-
key -- latin-1 可编码文本键名
-
value -- 此键、文本或
PIL.PngImagePlugin.iTXt实例的值 -
zip -- 压缩标志
-
TarIO 模块
-
classPIL.TarIO.TarIO(tarfile, file) -
基类:
PIL.ContainerIO.ContainerIO提供对TAR文件中给定成员的读访问的文件对象。
-
close()
-
WalImageFile 模块
本阅读器基于可从以下网站获得的规范:https://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml并用google找到的几个示例文件进行了测试。
-
PIL.WalImageFile.open(filename) -
从Quake2 Wal纹理文件加载纹理。
默认情况下,Quake2 标准调色板附加到纹理。要覆盖调色板,请使用
PIL.Image.Image.putpalette()方法。- 参数
-
filename -- wal文件名或打开的文件句柄。
- 返回
-
一个Image实例。
此格式无法自动识别,因此阅读器未注册使用PIL.Image.open(). 要打开 WAL 文件,请改用该PIL.WalImageFile.open()函数。