插件参考¶
BmpImagePlugin Module¶
-
class
PIL.BmpImagePlugin.BmpImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.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.DibImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.BmpImagePlugin.BmpImageFile-
format= 'DIB'¶
-
format_description= 'Windows Bitmap'¶
-
BufrStubImagePlugin Module¶
CurImagePlugin Module¶
-
class
PIL.CurImagePlugin.CurImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.BmpImagePlugin.BmpImageFile-
format= 'CUR'¶
-
format_description= 'Windows Cursor'¶
-
DcxImagePlugin Module¶
-
class
PIL.DcxImagePlugin.DcxImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.PcxImagePlugin.PcxImageFile-
format= 'DCX'¶
-
format_description= 'Intel DCX'¶
-
property
is_animated¶
-
property
n_frames¶
-
seek(frame)[源代码]¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an EOFError exception. When a sequence file is opened, the library automatically seeks to frame 0.
See
tell().- 参数
frame – Frame number, starting at 0.
- 引发
EOFError – If the call attempts to seek beyond the end of the sequence.
-
EpsImagePlugin Module¶
-
class
PIL.EpsImagePlugin.EpsImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFileEPS File Parser for the Python Imaging Library
-
format= 'EPS'¶
-
format_description= 'Encapsulated Postscript'¶
-
mode_map= {1: 'L', 2: 'LAB', 3: 'RGB', 4: 'CMYK'}¶
-
FitsStubImagePlugin Module¶
FliImagePlugin Module¶
-
class
PIL.FliImagePlugin.FliImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFile-
format= 'FLI'¶
-
format_description= 'Autodesk FLI/FLC Animation'¶
-
property
is_animated¶
-
property
n_frames¶
-
seek(frame)[源代码]¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an EOFError exception. When a sequence file is opened, the library automatically seeks to frame 0.
See
tell().- 参数
frame – Frame number, starting at 0.
- 引发
EOFError – If the call attempts to seek beyond the end of the sequence.
-
FpxImagePlugin Module¶
GbrImagePlugin Module¶
GifImagePlugin Module¶
-
class
PIL.GifImagePlugin.GifImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFile-
format= 'GIF'¶
-
format_description= 'Compuserve GIF'¶
-
global_palette= None¶
-
property
is_animated¶
-
property
n_frames¶
-
seek(frame)[源代码]¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an EOFError exception. When a sequence file is opened, the library automatically seeks to frame 0.
See
tell().- 参数
frame – Frame number, starting at 0.
- 引发
EOFError – If the call attempts to seek beyond the end of the sequence.
-
-
PIL.GifImagePlugin.getdata(im, offset=(0, 0), **params)[源代码]¶ Legacy Method
Return a list of strings representing this image. The first string is a local image header, the rest contains encoded image data.
- 参数
im – Image object
offset – Tuple of (x, y) pixels. Defaults to (0,0)
**params – E.g. duration or other encoder info parameters
- 返回
List of Bytes containing gif encoded frame data
GribStubImagePlugin Module¶
Hdf5StubImagePlugin Module¶
IcnsImagePlugin Module¶
-
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>)]}¶
-
-
class
PIL.IcnsImagePlugin.IcnsImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFilePIL image support for Mac OS .icns files. Chooses the best resolution, but will possibly load a different size image if you mutate the size attribute before calling ‘load’.
The info dictionary has a key ‘sizes’ that is a list of sizes that the icns file has.
-
format= 'ICNS'¶
-
format_description= 'Mac OS icns resource'¶
-
property
size¶
-
IcoImagePlugin Module¶
-
class
PIL.IcoImagePlugin.IcoImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFilePIL read-only image support for Microsoft Windows .ico files.
By default the largest resolution image in the file will be loaded. This can be changed by altering the ‘size’ attribute before calling ‘load’.
The info dictionary has a key ‘sizes’ that is a list of the sizes available in the icon file.
Handles classic, XP and Vista icon formats.
When saving, PNG compression is used. Support for this was only added in Windows Vista.
This plugin is a refactored version of Win32IconImagePlugin by Bryan Davis <casadebender@gmail.com>. https://code.google.com/archive/p/casadebender/wikis/Win32IconImagePlugin.wiki
-
format= 'ICO'¶
-
format_description= 'Windows Icon'¶
-
property
size¶
-
ImImagePlugin Module¶
-
class
PIL.ImImagePlugin.ImImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFile-
format= 'IM'¶
-
format_description= 'IFUNC Image Memory'¶
-
property
is_animated¶
-
property
n_frames¶
-
seek(frame)[源代码]¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an EOFError exception. When a sequence file is opened, the library automatically seeks to frame 0.
See
tell().- 参数
frame – Frame number, starting at 0.
- 引发
EOFError – If the call attempts to seek beyond the end of the sequence.
-
ImtImagePlugin Module¶
IptcImagePlugin Module¶
-
class
PIL.IptcImagePlugin.IptcImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFile-
format= 'IPTC'¶
-
format_description= 'IPTC/NAA'¶
-
JpegImagePlugin Module¶
-
class
PIL.JpegImagePlugin.JpegImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFile-
draft(mode, size)[源代码]¶ Configures the image file loader so it returns a version of the image that as closely as possible matches the given mode and size. For example, you can use this method to convert a color JPEG to greyscale while loading it.
If any changes are made, returns a tuple with the chosen
modeandboxwith coordinates of the original image within the altered one.Note that this method modifies the
Imageobject in place. If the image has already been loaded, this method has no effect.Note: This method is not implemented for most images. It is currently implemented only for JPEG and MPO images.
- 参数
mode – The requested mode.
size – The requested size.
-
format= 'JPEG'¶
-
format_description= 'JPEG (ISO 10918)'¶
-
Jpeg2KImagePlugin Module¶
McIdasImagePlugin Module¶
MicImagePlugin Module¶
PcdImagePlugin Module¶
PcxImagePlugin Module¶
PdfImagePlugin Module¶
PixarImagePlugin Module¶
PngImagePlugin Module¶
-
PIL.PngImagePlugin.getchunks(im, **params)[源代码]¶ Return a list of PNG chunks representing this image.
-
PIL.PngImagePlugin.is_cid()¶ Matches zero or more characters at the beginning of the string.
-
class
PIL.PngImagePlugin.PngImageFile(fp=None, filename=None)[源代码] 基类:
PIL.ImageFile.ImageFile-
format= 'PNG'¶
-
format_description= 'Portable network graphics'¶
-
load_end()[源代码] internal: finished reading image data
-
load_prepare()[源代码] internal: prepare to read PNG file
-
load_read(read_bytes)[源代码] internal: read more image data
-
property
text¶
-
verify()[源代码] Verify PNG file
-
PpmImagePlugin Module¶
PsdImagePlugin Module¶
-
class
PIL.PsdImagePlugin.PsdImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFile-
format= 'PSD'¶
-
format_description= 'Adobe Photoshop'¶
-
property
is_animated¶
-
property
n_frames¶
-
seek(layer)[源代码]¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an EOFError exception. When a sequence file is opened, the library automatically seeks to frame 0.
See
tell().- 参数
frame – Frame number, starting at 0.
- 引发
EOFError – If the call attempts to seek beyond the end of the sequence.
-
SpiderImagePlugin Module¶
-
class
PIL.SpiderImagePlugin.SpiderImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFile-
format= 'SPIDER'¶
-
format_description= 'Spider 2D image'¶
-
property
is_animated¶
-
property
n_frames¶
-
seek(frame)[源代码]¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an EOFError exception. When a sequence file is opened, the library automatically seeks to frame 0.
See
tell().- 参数
frame – Frame number, starting at 0.
- 引发
EOFError – If the call attempts to seek beyond the end of the sequence.
-
SunImagePlugin Module¶
TgaImagePlugin Module¶
TiffImagePlugin Module¶
-
class
PIL.TiffImagePlugin.AppendingTiffWriter(fn, new=False)[源代码]¶ 基类:
object-
Tags= {273, 288, 324, 519, 520, 521}¶
-
fieldSizes= [0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8]¶
-
-
class
PIL.TiffImagePlugin.IFDRational(value, denominator=1)[源代码]¶ 基类:
numbers.RationalImplements a rational class where 0/0 is a legal value to match the in the wild use of exif rationals.
e.g., DigitalZoomRatio - 0.00/0.00 indicates that no digital zoom was used
-
property
denominator¶
-
limit_rational(max_denominator)[源代码]¶ - 参数
max_denominator – Integer, the maximum denominator value
- 返回
Tuple of (numerator, denominator)
-
property
numerator¶
-
property
-
PIL.TiffImagePlugin.ImageFileDirectory¶
-
class
PIL.TiffImagePlugin.ImageFileDirectory_v1(*args, **kwargs)[源代码]¶ 基类:
PIL.TiffImagePlugin.ImageFileDirectory_v2This class represents the legacy interface to a TIFF tag directory.
Exposes a dictionary interface of the tags in the directory:
ifd = ImageFileDirectory_v1() ifd[key] = 'Some Data' ifd.tagtype[key] = TiffTags.ASCII print(ifd[key]) ('Some Data',)
Also contains a dictionary of tag types as read from the tiff image file, ~PIL.TiffImagePlugin.ImageFileDirectory_v1.tagtype.
Values are returned as a tuple.
3.0.0 版后已移除.
-
classmethod
from_v2(original)[源代码]¶ Returns an
ImageFileDirectory_v1instance with the same data as is contained in the originalImageFileDirectory_v2instance.
-
property
tagdata¶
-
to_v2()[源代码]¶ Returns an
ImageFileDirectory_v2instance with the same data as is contained in the originalImageFileDirectory_v1instance.
-
classmethod
-
class
PIL.TiffImagePlugin.ImageFileDirectory_v2(ifh=b'II*x00x00x00x00x00', prefix=None)[源代码]¶ 基类:
collections.abc.MutableMappingThis class represents a TIFF tag directory. To speed things up, we don’t decode tags unless they’re asked for.
Exposes a dictionary interface of the tags in the directory:
ifd = ImageFileDirectory_v2() ifd[key] = 'Some Data' ifd.tagtype[key] = TiffTags.ASCII print(ifd[key]) 'Some Data'
Individual values are returned as the strings or numbers, sequences are returned as tuples of the values.
The tiff metadata type of each item is stored in a dictionary of tag types in ~PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype. The types are read from a tiff file, guessed from the type added, or added manually.
Data Structures:
self.tagtype = {}
Key: numerical tiff tag number
- Value: integer corresponding to the data type from
~PIL.TiffTags.TYPES`
3.0.0 新版功能.
-
property
legacy_api¶
-
load_double(data, legacy_api=True)¶
-
load_float(data, legacy_api=True)¶
-
load_long(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_short(data, legacy_api=True)¶
-
named()[源代码]¶ - 返回
dict of name|key: value
Returns the complete tag dictionary, with named tags where possible.
-
property
offset¶
-
property
prefix¶
-
write_double(*values)¶
-
write_float(*values)¶
-
write_long(*values)¶
-
write_short(*values)¶
-
write_signed_byte(*values)¶
-
write_signed_long(*values)¶
-
write_signed_short(*values)¶
WebPImagePlugin Module¶
-
class
PIL.WebPImagePlugin.WebPImageFile(fp=None, filename=None)[源代码]¶ 基类:
PIL.ImageFile.ImageFile-
format= 'WEBP'¶
-
format_description= 'WebP image'¶
-
property
is_animated¶
-
property
n_frames¶
-
seek(frame)[源代码]¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an EOFError exception. When a sequence file is opened, the library automatically seeks to frame 0.
See
tell().- 参数
frame – Frame number, starting at 0.
- 引发
EOFError – If the call attempts to seek beyond the end of the sequence.
-