插件引用#

BmpImagePlugin 模块#

class PIL.BmpImagePlugin.BmpImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

Windows位图格式(BMP)的图像插件

BITFIELDS = 3#
COMPRESSIONS = {'BITFIELDS': 3, 'JPEG': 4, 'PNG': 5, 'RAW': 0, 'RLE4': 2, 'RLE8': 1}#
JPEG = 4#
PNG = 5#
RAW = 0#
RLE4 = 2#
RLE8 = 1#
format = 'BMP'#
format_description = 'Windows Bitmap'#
k = 'PNG'#
v = 5#
class PIL.BmpImagePlugin.BmpRleDecoder(mode, *args)[源代码]#

基类:PyDecoder

decode(buffer)[源代码]#

重写以执行解码过程。

参数:

buffer -- 带有要解码的数据的bytes对象。

返回:

的元组 (bytes consumed, errcode) 。如果完成解码,则为消耗的字节返回-1。错误代码来自 ImageFile.ERRORS

class PIL.BmpImagePlugin.DibImageFile(fp=None, filename=None)[源代码]#

基类:BmpImageFile

format = 'DIB'#
format_description = 'Windows Bitmap'#

BufrStubImagePlugin 模块#

class PIL.BufrStubImagePlugin.BufrStubImageFile(fp=None, filename=None)[源代码]#

基类:StubImageFile

format = 'BUFR'#
format_description = 'BUFR'#
PIL.BufrStubImagePlugin.register_handler(handler)[源代码]#

安装特定于应用程序的BUFR映像处理程序。

参数:

handler -- 处理程序对象。

CurImagePlugin 模块#

class PIL.CurImagePlugin.CurImageFile(fp=None, filename=None)[源代码]#

基类:BmpImageFile

format = 'CUR'#
format_description = 'Windows Cursor'#

DcxImagePlugin 模块#

class PIL.DcxImagePlugin.DcxImageFile(fp=None, filename=None)[源代码]#

基类:PcxImageFile

format = 'DCX'#
format_description = 'Intel DCX'#
seek(frame)[源代码]#

查找此序列文件中的给定帧。如果在序列结尾之外查找,该方法将引发 EOFError 例外。打开序列文件时,库自动查找第0帧。

tell() .

如果定义了, n_frames 指可用帧数。

参数:

frame -- 帧编号,从0开始。

抛出:

EOFError -- 如果调用试图在序列结束后查找。

tell()[源代码]#

返回当前帧号。见 seek() .

如果定义了, n_frames 指可用帧数。

返回:

帧编号,从0开始。

EpsImagePlugin 模块#

class PIL.EpsImagePlugin.EpsImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

python图像库的eps文件分析器

format = 'EPS'#
format_description = 'Encapsulated Postscript'#
load(scale=1, transparency=False)[源代码]#

基于平铺列表加载图像数据

load_seek(*args, **kwargs)[源代码]#
mode_map = {1: 'L', 2: 'LAB', 3: 'RGB', 4: 'CMYK'}#
PIL.EpsImagePlugin.Ghostscript(tile, size, fp, scale=1, transparency=False)[源代码]#

使用ghostscript渲染图像

class PIL.EpsImagePlugin.PSFile(fp)[源代码]#

基类:object

将CR或LF视为行尾的bytesio对象的包装。这个类不再在内部使用,而是为了向后兼容而保留。

readline()[源代码]#
seek(offset, whence=0)[源代码]#
PIL.EpsImagePlugin.has_ghostscript()[源代码]#

FitsImagePlugin 模块#

class PIL.FitsImagePlugin.FitsImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'FITS'#
format_description = 'FITS'#

FliImagePlugin 模块#

class PIL.FliImagePlugin.FliImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'FLI'#
format_description = 'Autodesk FLI/FLC Animation'#
seek(frame)[源代码]#

查找此序列文件中的给定帧。如果在序列结尾之外查找,该方法将引发 EOFError 例外。打开序列文件时,库自动查找第0帧。

tell() .

如果定义了, n_frames 指可用帧数。

参数:

frame -- 帧编号,从0开始。

抛出:

EOFError -- 如果调用试图在序列结束后查找。

tell()[源代码]#

返回当前帧号。见 seek() .

如果定义了, n_frames 指可用帧数。

返回:

帧编号,从0开始。

FpxImagePlugin 模块#

class PIL.FpxImagePlugin.FpxImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

close()[源代码]#

如果可能,关闭文件指针。

此操作将破坏图像核心并释放其内存。之后图像数据将无法使用。

关闭具有多个帧的图像或尚未读取并关闭其文件的图像时,需要使用此函数 load() 方法。看见 Pillow中的文件处理 了解更多信息。

format = 'FPX'#
format_description = 'FlashPix'#
load()[源代码]#

基于平铺列表加载图像数据

GbrImagePlugin 模块#

class PIL.GbrImagePlugin.GbrImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'GBR'#
format_description = 'GIMP brush file'#
load()[源代码]#

基于平铺列表加载图像数据

GifImagePlugin 模块#

class PIL.GifImagePlugin.GifImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

data()[源代码]#
format = 'GIF'#
format_description = 'Compuserve GIF'#
global_palette = None#
property is_animated#
load_end()[源代码]#
load_prepare()[源代码]#
property n_frames#
seek(frame)[源代码]#

查找此序列文件中的给定帧。如果在序列结尾之外查找,该方法将引发 EOFError 例外。打开序列文件时,库自动查找第0帧。

tell() .

如果定义了, n_frames 指可用帧数。

参数:

frame -- 帧编号,从0开始。

抛出:

EOFError -- 如果调用试图在序列结束后查找。

tell()[源代码]#

返回当前帧号。见 seek() .

如果定义了, n_frames 指可用帧数。

返回:

帧编号,从0开始。

PIL.GifImagePlugin.LOADING_STRATEGY = LoadingStrategy.RGB_AFTER_FIRST#

在 9.1.0 版本加入.

class PIL.GifImagePlugin.LoadingStrategy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]#

基类:IntEnum

在 9.1.0 版本加入.

RGB_AFTER_DIFFERENT_PALETTE_ONLY = 1#
RGB_AFTER_FIRST = 0#
RGB_ALWAYS = 2#
PIL.GifImagePlugin.get_interlace(im)[源代码]#
PIL.GifImagePlugin.getdata(im, offset=(0, 0), **params)[源代码]#

遗留方法

返回表示此图像的字符串列表。第一个字符串是本地图像头,其余字符串包含编码的图像数据。

要指定持续时间,请添加以毫秒为单位的时间,例如 getdata(im_frame, duration=1000)

参数:
  • im -- 图像对象

  • offset -- (x,y)像素的元组。默认为(0,0)

  • **params -- 例如持续时间或其他编码器信息参数

返回:

包含GIF编码帧数据的字节列表

PIL.GifImagePlugin.getheader(im, palette=None, info=None)[源代码]#

从图像中获取GIF数据的传统方法。

警告::可能会修改图像数据。

参数:
  • im -- 图像对象

  • palette -- 包含源调色板的bytes对象,或….

  • info -- 编码信息

返回:

(标题项列表,优化调色板)的元组

GribStubImagePlugin 模块#

class PIL.GribStubImagePlugin.GribStubImageFile(fp=None, filename=None)[源代码]#

基类:StubImageFile

format = 'GRIB'#
format_description = 'GRIB'#
PIL.GribStubImagePlugin.register_handler(handler)[源代码]#

安装特定于应用程序的GRIB映像处理程序。

参数:

handler -- 处理程序对象。

Hdf5StubImagePlugin 模块#

class PIL.Hdf5StubImagePlugin.HDF5StubImageFile(fp=None, filename=None)[源代码]#

基类:StubImageFile

format = 'HDF5'#
format_description = 'HDF5'#
PIL.Hdf5StubImagePlugin.register_handler(handler)[源代码]#

安装特定于应用程序的HDF5图像处理程序。

参数:

handler -- 处理程序对象。

IcnsImagePlugin 模块#

class PIL.IcnsImagePlugin.IcnsFile(fobj)[源代码]#

基类:object

SIZES = {(16, 16, 1): [(b'icp4', <function read_png_or_jpeg2000>), (b'is32', <function read_32>), (b's8mk', <function read_mk>)], (16, 16, 2): [(b'ic11', <function read_png_or_jpeg2000>)], (32, 32, 1): [(b'icp5', <function read_png_or_jpeg2000>), (b'il32', <function read_32>), (b'l8mk', <function read_mk>)], (32, 32, 2): [(b'ic12', <function read_png_or_jpeg2000>)], (48, 48, 1): [(b'ih32', <function read_32>), (b'h8mk', <function read_mk>)], (64, 64, 1): [(b'icp6', <function read_png_or_jpeg2000>)], (128, 128, 1): [(b'ic07', <function read_png_or_jpeg2000>), (b'it32', <function read_32t>), (b't8mk', <function read_mk>)], (128, 128, 2): [(b'ic13', <function read_png_or_jpeg2000>)], (256, 256, 1): [(b'ic08', <function read_png_or_jpeg2000>)], (256, 256, 2): [(b'ic14', <function read_png_or_jpeg2000>)], (512, 512, 1): [(b'ic09', <function read_png_or_jpeg2000>)], (512, 512, 2): [(b'ic10', <function read_png_or_jpeg2000>)]}#
bestsize()[源代码]#
dataforsize(size)[源代码]#

获取图标资源作为通道:数组。请注意,数组是自底向上的,类似于Windows位图,可能需要以某种方式翻转或转置。

getimage(size=None)[源代码]#
itersizes()[源代码]#
class PIL.IcnsImagePlugin.IcnsImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

对mac os.icns文件的pil映像支持。选择最佳分辨率,但如果在调用“load”之前改变大小属性,则可能加载不同大小的图像。

信息字典有一个键“大小”,它是ICN文件的大小列表。

format = 'ICNS'#
format_description = 'Mac OS icns resource'#
load()[源代码]#

基于平铺列表加载图像数据

property size#
PIL.IcnsImagePlugin.nextheader(fobj)[源代码]#
PIL.IcnsImagePlugin.read_32(fobj, start_length, size)[源代码]#

读取32位RGB图标资源。似乎要么是未压缩的,要么是一个像rle-packbits的方案。

PIL.IcnsImagePlugin.read_32t(fobj, start_length, size)[源代码]#
PIL.IcnsImagePlugin.read_mk(fobj, start_length, size)[源代码]#
PIL.IcnsImagePlugin.read_png_or_jpeg2000(fobj, start_length, size)[源代码]#

IcoImagePlugin 模块#

class PIL.IcoImagePlugin.IcoFile(buf)[源代码]#

基类:object

frame(idx)[源代码]#

从帧IDX获取图像

getentryindex(size, bpp=False)[源代码]#
getimage(size, bpp=False)[源代码]#

从图标中获取图像

sizes()[源代码]#

获取所有可用图标大小和颜色深度的列表。

class PIL.IcoImagePlugin.IcoImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

PIL只读图像支持Microsoft Windows.ico文件。

默认情况下,将加载文件中的最大分辨率图像。这可以通过在调用“load”之前更改“size”属性来更改。

信息字典有一个键“大小”,它是图标文件中可用大小的列表。

处理经典、XP和Vista图标格式。

保存时,使用PNG压缩。仅在Windows Vista中添加了对此的支持。如果无法在Windows中查看图标,请在保存前将图像转换为“RGBA”模式。

此插件是bryan davis<casadebender@gmail.com>重构的win32iconimageplugin版本。https://code.google.com/archive/p/casadebender/wikis/win32iconimageplugin.wiki

format = 'ICO'#
format_description = 'Windows Icon'#
load()[源代码]#

基于平铺列表加载图像数据

load_seek()[源代码]#
property size#

ImImagePlugin 模块#

class PIL.ImImagePlugin.ImImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'IM'#
format_description = 'IFUNC Image Memory'#
property is_animated#
property n_frames#
seek(frame)[源代码]#

查找此序列文件中的给定帧。如果在序列结尾之外查找,该方法将引发 EOFError 例外。打开序列文件时,库自动查找第0帧。

tell() .

如果定义了, n_frames 指可用帧数。

参数:

frame -- 帧编号,从0开始。

抛出:

EOFError -- 如果调用试图在序列结束后查找。

tell()[源代码]#

返回当前帧号。见 seek() .

如果定义了, n_frames 指可用帧数。

返回:

帧编号,从0开始。

PIL.ImImagePlugin.number(s)[源代码]#

ImtImagePlugin 模块#

class PIL.ImtImagePlugin.ImtImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'IMT'#
format_description = 'IM Tools'#

IptcImagePlugin 模块#

class PIL.IptcImagePlugin.IptcImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

field()[源代码]#
format = 'IPTC'#
format_description = 'IPTC/NAA'#
getint(key)[源代码]#
load()[源代码]#

基于平铺列表加载图像数据

PIL.IptcImagePlugin.dump(c)[源代码]#
PIL.IptcImagePlugin.getiptcinfo(im)[源代码]#

从TIFF、JPEG或IPTC文件获取IPTC信息。

参数:

im -- 包含IPTC数据的图像。

返回:

包含IPTC信息的字典,如果找不到IPTC信息块,则为“无”。

PIL.IptcImagePlugin.i(c)[源代码]#

JpegImagePlugin 模块#

PIL.JpegImagePlugin.APP(self, marker)[源代码]#
PIL.JpegImagePlugin.COM(self, marker)[源代码]#
PIL.JpegImagePlugin.DQT(self, marker)[源代码]#
class PIL.JpegImagePlugin.JpegImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

draft(mode, size)[源代码]#

配置 Mapfile 加载程序,使其返回尽可能与给定模式和大小匹配的映像版本。例如,可以使用此方法在加载彩色JPEG时将其转换为灰度。

如果进行了任何更改,则返回一个带有 modebox 原始图像的坐标在修改后的图像内。

请注意,此方法修改了 Image 物体就位。如果图像已加载,则此方法无效。

注意:此方法不适用于大多数图像。它目前只为JPEG和MPO图像实现。

参数:
  • mode -- 请求的模式。

  • size -- 以像素为单位的请求大小,作为2元组:(宽度、高度)。

format = 'JPEG'#
format_description = 'JPEG (ISO 10918)'#
getxmp()[源代码]#

返回包含XMP标记的词典。需要安装DefusedXML。

返回:

词典中的XMP标签。

load_djpeg()[源代码]#
load_read(read_bytes)[源代码]#

内部:为过早的EOF读取更多的图像数据,并加载“截断”的图像添加EOI标记,以便libjpeg完成解码。

PIL.JpegImagePlugin.SOF(self, marker)[源代码]#
PIL.JpegImagePlugin.Skip(self, marker)[源代码]#
PIL.JpegImagePlugin.get_sampling(im)[源代码]#
PIL.JpegImagePlugin.jpeg_factory(fp=None, filename=None)[源代码]#

Jpeg2KImagePlugin 模块#

class PIL.Jpeg2KImagePlugin.BoxReader(fp, length=-1)[源代码]#

基类:object

一个小帮助器类,用于读取存储在JPEG2000标题框中的字段,并轻松地步入和读取子框。

has_next_box()[源代码]#
next_box_type()[源代码]#
read_boxes()[源代码]#
read_fields(field_format)[源代码]#
class PIL.Jpeg2KImagePlugin.Jpeg2KImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'JPEG2000'#
format_description = 'JPEG 2000 (ISO 15444)'#
load()[源代码]#

基于平铺列表加载图像数据

property reduce#

返回缩小的图像的副本 factor 泰晤士报。如果图像的大小不能被 factor ,则结果大小将向上舍入。

参数:
  • factor -- 宽度和高度分别大于0的整数或两个整数的元组。

  • box -- 提供要缩小的源图像区域的可选4元组整数。这些值必须在 (0, 0, width, height) 矩形。如果省略或 None ,则使用整个源。

McIdasImagePlugin 模块#

class PIL.McIdasImagePlugin.McIdasImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'MCIDAS'#
format_description = 'McIdas area file'#

MicImagePlugin 模块#

class PIL.MicImagePlugin.MicImageFile(fp=None, filename=None)[源代码]#

基类:TiffImageFile

close()[源代码]#

如果可能,关闭文件指针。

此操作将破坏图像核心并释放其内存。之后图像数据将无法使用。

关闭具有多个帧的图像或尚未读取并关闭其文件的图像时,需要使用此函数 load() 方法。看见 Pillow中的文件处理 了解更多信息。

format = 'MIC'#
format_description = 'Microsoft Image Composer'#
seek(frame)[源代码]#

选择给定帧作为当前图像

tell()[源代码]#

返回当前帧号

MpegImagePlugin 模块#

class PIL.MpegImagePlugin.BitStream(fp)[源代码]#

基类:object

next()[源代码]#
peek(bits)[源代码]#
read(bits)[源代码]#
skip(bits)[源代码]#
class PIL.MpegImagePlugin.MpegImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'MPEG'#
format_description = 'MPEG'#

MspImagePlugin 模块#

class PIL.MspImagePlugin.MspDecoder(mode, *args)[源代码]#

基类:PyDecoder

decode(buffer)[源代码]#

重写以执行解码过程。

参数:

buffer -- 带有要解码的数据的bytes对象。

返回:

的元组 (bytes consumed, errcode) 。如果完成解码,则为消耗的字节返回-1。错误代码来自 ImageFile.ERRORS

class PIL.MspImagePlugin.MspImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'MSP'#
format_description = 'Windows Paint'#

PalmImagePlugin 模块#

PIL.PalmImagePlugin.build_prototype_image()[源代码]#

PcdImagePlugin 模块#

class PIL.PcdImagePlugin.PcdImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'PCD'#
format_description = 'Kodak PhotoCD'#
load_end()[源代码]#

PcxImagePlugin 模块#

class PIL.PcxImagePlugin.PcxImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'PCX'#
format_description = 'Paintbrush'#

PdfImagePlugin 模块#

PixarImagePlugin 模块#

class PIL.PixarImagePlugin.PixarImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'PIXAR'#
format_description = 'PIXAR raster image'#

PngImagePlugin 模块#

class PIL.PngImagePlugin.Blend(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]#

基类:IntEnum

OP_OVER = 1#

该帧应该与先前的输出图像内容进行Alpha合成。看见 Saving APNG sequences

OP_SOURCE = 0#

该帧的所有颜色分量,包括Alpha,都会覆盖以前的输出图像内容。看见 Saving APNG sequences

class PIL.PngImagePlugin.ChunkStream(fp)[源代码]#

基类:object

call(cid, pos, length)[源代码]#

调用适当的块处理程序

close()[源代码]#
crc(cid, data)[源代码]#

读取并验证校验和

crc_skip(cid, data)[源代码]#

读取校验和

push(cid, pos, length)[源代码]#
read()[源代码]#

获取新块。返回头信息。

verify(endchunk=b'IEND')[源代码]#
class PIL.PngImagePlugin.Disposal(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]#

基类:IntEnum

OP_BACKGROUND = 1#

在渲染下一帧之前,该帧的修改区域被清除为完全透明的黑色。看见 Saving APNG sequences

OP_NONE = 0#

在渲染下一帧之前,不会对该帧进行任何处理。看见 Saving APNG sequences

OP_PREVIOUS = 2#

在渲染下一帧之前,该帧的修改区域将恢复为上一帧的内容。看见 Saving APNG sequences

class PIL.PngImagePlugin.PngImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

getexif()[源代码]#

从图像中获取EXIF数据。

返回:

一个 Exif 对象。

getxmp()[源代码]#

返回包含XMP标记的词典。需要安装DefusedXML。

返回:

词典中的XMP标签。

load_end()[源代码]#

内部:读取完图像数据

load_prepare()[源代码]#

内部:准备读取PNG文件

load_read(read_bytes)[源代码]#

内部:读取更多图像数据

seek(frame)[源代码]#

查找此序列文件中的给定帧。如果在序列结尾之外查找,该方法将引发 EOFError 例外。打开序列文件时,库自动查找第0帧。

tell() .

如果定义了, n_frames 指可用帧数。

参数:

frame -- 帧编号,从0开始。

抛出:

EOFError -- 如果调用试图在序列结束后查找。

tell()[源代码]#

返回当前帧号。见 seek() .

如果定义了, n_frames 指可用帧数。

返回:

帧编号,从0开始。

verify()[源代码]#

验证PNG文件

format = 'PNG'#
format_description = 'Portable network graphics'#
property text#
class PIL.PngImagePlugin.PngStream(fp)[源代码]#

基类:ChunkStream

check_text_memory(chunklen)[源代码]#
chunk_IDAT(pos, length)[源代码]#
chunk_IEND(pos, length)[源代码]#
chunk_IHDR(pos, length)[源代码]#
chunk_PLTE(pos, length)[源代码]#
chunk_acTL(pos, length)[源代码]#
chunk_cHRM(pos, length)[源代码]#
chunk_eXIf(pos, length)[源代码]#
chunk_fcTL(pos, length)[源代码]#
chunk_fdAT(pos, length)[源代码]#
chunk_gAMA(pos, length)[源代码]#
chunk_iCCP(pos, length)[源代码]#
chunk_iTXt(pos, length)[源代码]#
chunk_pHYs(pos, length)[源代码]#
chunk_sRGB(pos, length)[源代码]#
chunk_tEXt(pos, length)[源代码]#
chunk_tRNS(pos, length)[源代码]#
chunk_zTXt(pos, length)[源代码]#
rewind()[源代码]#
save_rewind()[源代码]#
PIL.PngImagePlugin.getchunks(im, **params)[源代码]#

返回表示此图像的PNG块列表。

PIL.PngImagePlugin.is_cid(string, pos=0, endpos=9223372036854775807)#

匹配字符串开头的零个或多个字符。

PIL.PngImagePlugin.putchunk(fp, cid, *data)[源代码]#

写入PNG块(包括CRC字段)

PIL.PngImagePlugin.MAX_TEXT_CHUNK = 1048576#

ITXT或zTXt块的最大解压缩大小。消除了压缩块可以扩展1000倍的解压缩炸弹。看见 Text in PNG File Format

PIL.PngImagePlugin.MAX_TEXT_MEMORY = 67108864#

设置最大总文本块大小。看见 Text in PNG File Format

PpmImagePlugin 模块#

class PIL.PpmImagePlugin.PpmDecoder(mode, *args)[源代码]#

基类:PyDecoder

decode(buffer)[源代码]#

重写以执行解码过程。

参数:

buffer -- 带有要解码的数据的bytes对象。

返回:

的元组 (bytes consumed, errcode) 。如果完成解码,则为消耗的字节返回-1。错误代码来自 ImageFile.ERRORS

class PIL.PpmImagePlugin.PpmImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'PPM'#
format_description = 'Pbmplus image'#
class PIL.PpmImagePlugin.PpmPlainDecoder(mode, *args)[源代码]#

基类:PyDecoder

decode(buffer)[源代码]#

重写以执行解码过程。

参数:

buffer -- 带有要解码的数据的bytes对象。

返回:

的元组 (bytes consumed, errcode) 。如果完成解码,则为消耗的字节返回-1。错误代码来自 ImageFile.ERRORS

PsdImagePlugin 模块#

class PIL.PsdImagePlugin.PsdImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'PSD'#
format_description = 'Adobe Photoshop'#
seek(layer)[源代码]#

查找此序列文件中的给定帧。如果在序列结尾之外查找,该方法将引发 EOFError 例外。打开序列文件时,库自动查找第0帧。

tell() .

如果定义了, n_frames 指可用帧数。

参数:

frame -- 帧编号,从0开始。

抛出:

EOFError -- 如果调用试图在序列结束后查找。

tell()[源代码]#

返回当前帧号。见 seek() .

如果定义了, n_frames 指可用帧数。

返回:

帧编号,从0开始。

SgiImagePlugin 模块#

class PIL.SgiImagePlugin.SGI16Decoder(mode, *args)[源代码]#

基类:PyDecoder

decode(buffer)[源代码]#

重写以执行解码过程。

参数:

buffer -- 带有要解码的数据的bytes对象。

返回:

的元组 (bytes consumed, errcode) 。如果完成解码,则为消耗的字节返回-1。错误代码来自 ImageFile.ERRORS

class PIL.SgiImagePlugin.SgiImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'SGI'#
format_description = 'SGI Image File Format'#

SpiderImagePlugin 模块#

class PIL.SpiderImagePlugin.SpiderImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

convert2byte(depth=255)[源代码]#
format = 'SPIDER'#
format_description = 'Spider 2D image'#
property is_animated#
property n_frames#
seek(frame)[源代码]#

查找此序列文件中的给定帧。如果在序列结尾之外查找,该方法将引发 EOFError 例外。打开序列文件时,库自动查找第0帧。

tell() .

如果定义了, n_frames 指可用帧数。

参数:

frame -- 帧编号,从0开始。

抛出:

EOFError -- 如果调用试图在序列结束后查找。

tell()[源代码]#

返回当前帧号。见 seek() .

如果定义了, n_frames 指可用帧数。

返回:

帧编号,从0开始。

tkPhotoImage()[源代码]#
PIL.SpiderImagePlugin.isInt(f)[源代码]#
PIL.SpiderImagePlugin.isSpiderHeader(t)[源代码]#
PIL.SpiderImagePlugin.isSpiderImage(filename)[源代码]#
PIL.SpiderImagePlugin.loadImageSeries(filelist=None)[源代码]#

创建的列表 Image 蒙太奇中使用的对象

PIL.SpiderImagePlugin.makeSpiderHeader(im)[源代码]#

SunImagePlugin 模块#

class PIL.SunImagePlugin.SunImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'SUN'#
format_description = 'Sun Raster File'#

TgaImagePlugin 模块#

class PIL.TgaImagePlugin.TgaImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'TGA'#
format_description = 'Targa'#
load_end()[源代码]#

TiffImagePlugin 模块#

class PIL.TiffImagePlugin.AppendingTiffWriter(fn, new=False)[源代码]#

基类:object

Tags = {273, 288, 324, 519, 520, 521}#
close()[源代码]#
fieldSizes = [0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4, 2, 4, 8]#
finalize()[源代码]#
fixIFD()[源代码]#
fixOffsets(count, isShort=False, isLong=False)[源代码]#
goToEnd()[源代码]#
newFrame()[源代码]#
readLong()[源代码]#
readShort()[源代码]#
rewriteLastLong(value)[源代码]#
rewriteLastShort(value)[源代码]#
rewriteLastShortToLong(value)[源代码]#
seek(offset, whence=0)[源代码]#
setEndian(endian)[源代码]#
setup()[源代码]#
skipIFDs()[源代码]#
tell()[源代码]#
write(data)[源代码]#
writeLong(value)[源代码]#
writeShort(value)[源代码]#
class PIL.TiffImagePlugin.IFDRational(value, denominator=1)[源代码]#

基类:Rational

实现一个Rational类,其中0/0是一个合法值,以匹配在野外使用的exif理性。

例如,DigitalZoomRatio-0.00/0.00表示未使用数码变焦。

property denominator#
limit_rational(max_denominator)[源代码]#
参数:

max_denominator -- 整数,最大分母值

返回:

(分子、分母)的元组

property numerator#
PIL.TiffImagePlugin.ImageFileDirectory#

ImageFileDirectory_v1 的别名

class PIL.TiffImagePlugin.ImageFileDirectory_v1(*args, **kwargs)[源代码]#

基类:ImageFileDirectory_v2

此类表示 legacy 接口到TIFF标记目录。

显示目录中标记的字典接口::

ifd = ImageFileDirectory_v1()
ifd[key] = 'Some Data'
ifd.tagtype[key] = TiffTags.ASCII
print(ifd[key])
('Some Data',)

还包含从TIFF图像文件读取的标签类型的字典, tagtype

值作为元组返回。

自 3.0.0 版本弃用.

classmethod from_v2(original)[源代码]#

返回一个 ImageFileDirectory_v1 与原始中包含的数据相同的实例 ImageFileDirectory_v2 实例。

返回:

ImageFileDirectory_v1

property tagdata#
property tags#
tagtype: dict#

标签类型字典

to_v2()[源代码]#

返回一个 ImageFileDirectory_v2 与原始中包含的数据相同的实例 ImageFileDirectory_v1 实例。

返回:

ImageFileDirectory_v2

class PIL.TiffImagePlugin.ImageFileDirectory_v2(ifh=b'II*\x00\x00\x00\x00\x00', prefix=None, group=None)[源代码]#

基类:MutableMapping

此类表示TIFF标记目录。为了加快速度,我们不会解码标签,除非有人要求。

显示目录中标记的字典接口::

ifd = ImageFileDirectory_v2()
ifd[key] = 'Some Data'
ifd.tagtype[key] = TiffTags.ASCII
print(ifd[key])
'Some Data'

单个值作为字符串或数字返回,序列作为值的元组返回。

每个项目的TIFF元数据类型存储在中的标签类型字典中 tagtype 。类型从TIFF文件读取、从添加的类型猜测或手动添加。

数据结构:

  • self.tagtype = {}

    • 键:数字TIFF标签号

    • 值:与中的数据类型对应的整数 TiffTags.TYPES

    在 3.0.0 版本加入.

“内部”数据结构:

  • self._tags_v2 = {}

    • 键:数字TIFF标签号

    • 值:解码的数据,作为多个值的元组

  • self._tagdata = {}

    • 键:数字TIFF标签号

    • 值:来自文件的未解码字节串

  • self._tags_v1 = {}

    • 键:数字TIFF标签号

    • 值:v1格式的解码数据

标签将在私有属性中找到 self._tagdata ,以及在 self._tags_v2 一旦被破译。

self.legacy_api 是内部使用的值,不应从外部代码更改。与 ImageFileDirectory_v1 ,如果 legacy_api 为真,则解码的标记将填充到 _tags_v1_tags_v2_tags_v2 如果在TIFF保存例程中使用此IFD,则将使用此IFD。标签应从以下位置读取 _tags_v1 如果 legacy_api == true

property legacy_api#
load(fp)[源代码]#
load_byte(data, legacy_api=True)[源代码]#
load_double(data, legacy_api=True)#
load_float(data, legacy_api=True)#
load_long(data, legacy_api=True)#
load_long8(data, legacy_api=True)#
load_rational(data, legacy_api=True)[源代码]#
load_short(data, legacy_api=True)#
load_signed_byte(data, legacy_api=True)#
load_signed_long(data, legacy_api=True)#
load_signed_rational(data, legacy_api=True)[源代码]#
load_signed_short(data, legacy_api=True)#
load_string(data, legacy_api=True)[源代码]#
load_undefined(data, legacy_api=True)[源代码]#
named()[源代码]#
返回:

名称键的dict:value

返回完整的标记字典,尽可能使用命名标记。

property offset#
property prefix#
reset()[源代码]#
save(fp)[源代码]#
tagtype#

标签类型字典

tobytes(offset=0)[源代码]#
write_byte(data)[源代码]#
write_double(*values)#
write_float(*values)#
write_long(*values)#
write_long8(*values)#
write_rational(*values)[源代码]#
write_short(*values)#
write_signed_byte(*values)#
write_signed_long(*values)#
write_signed_rational(*values)[源代码]#
write_signed_short(*values)#
write_string(value)[源代码]#
write_undefined(value)[源代码]#
class PIL.TiffImagePlugin.TiffImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'TIFF'#
format_description = 'Adobe TIFF'#
get_photoshop_blocks()[源代码]#

返回Photoshop“图像资源块”的词典。密钥为图片资源ID,详情请参考https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_pgfId-1037727

返回:

Photoshop词典中的“图像资源块”。

getxmp()[源代码]#

返回包含XMP标记的词典。需要安装DefusedXML。

返回:

词典中的XMP标签。

load()[源代码]#

基于平铺列表加载图像数据

load_end()[源代码]#
property n_frames#
seek(frame)[源代码]#

选择给定帧作为当前图像

tag#

传统标签条目

tag_v2#

图像文件目录(标记字典)

tell()[源代码]#

返回当前帧号

WebPImagePlugin 模块#

class PIL.WebPImagePlugin.WebPImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'WEBP'#
format_description = 'WebP image'#
getxmp()[源代码]#

返回包含XMP标记的词典。需要安装DefusedXML。

返回:

词典中的XMP标签。

load()[源代码]#

基于平铺列表加载图像数据

seek(frame)[源代码]#

查找此序列文件中的给定帧。如果在序列结尾之外查找,该方法将引发 EOFError 例外。打开序列文件时,库自动查找第0帧。

tell() .

如果定义了, n_frames 指可用帧数。

参数:

frame -- 帧编号,从0开始。

抛出:

EOFError -- 如果调用试图在序列结束后查找。

tell()[源代码]#

返回当前帧号。见 seek() .

如果定义了, n_frames 指可用帧数。

返回:

帧编号,从0开始。

WmfImagePlugin 模块#

class PIL.WmfImagePlugin.WmfStubImageFile(fp=None, filename=None)[源代码]#

基类:StubImageFile

format = 'WMF'#
format_description = 'Windows Metafile'#
load(dpi=None)[源代码]#

基于平铺列表加载图像数据

PIL.WmfImagePlugin.register_handler(handler)[源代码]#

安装特定于应用程序的WMF映像处理程序。

参数:

handler -- 处理程序对象。

XVThumbImagePlugin 模块#

class PIL.XVThumbImagePlugin.XVThumbImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'XVThumb'#
format_description = 'XV thumbnail image'#

XbmImagePlugin 模块#

class PIL.XbmImagePlugin.XbmImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'XBM'#
format_description = 'X11 Bitmap'#

XpmImagePlugin 模块#

class PIL.XpmImagePlugin.XpmImageFile(fp=None, filename=None)[源代码]#

基类:ImageFile

format = 'XPM'#
format_description = 'X11 Pixel Map'#
load_read(bytes)[源代码]#