Plugin reference

BmpImagePlugin Module

class PIL.BmpImagePlugin.BmpImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

Image plugin for the Windows Bitmap format (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: str | None = 'BMP'
format_description: str | None = 'Windows Bitmap'
k = 'PNG'
v = 5
class PIL.BmpImagePlugin.BmpRleDecoder(mode: str, *args: Any)[source]

Bases: PyDecoder

decode(buffer: bytes | SupportsArrayInterface) tuple[int, int][source]

Override to perform the decoding process.

Parameters:

buffer – A bytes object with the data to be decoded.

Returns:

A tuple of (bytes consumed, errcode). If finished with decoding return -1 for the bytes consumed. Err codes are from ImageFile.ERRORS.

class PIL.BmpImagePlugin.DibImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: BmpImageFile

format: str | None = 'DIB'
format_description: str | None = 'Windows Bitmap'

BufrStubImagePlugin Module

class PIL.BufrStubImagePlugin.BufrStubImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: StubImageFile

format: str | None = 'BUFR'
format_description: str | None = 'BUFR'
PIL.BufrStubImagePlugin.register_handler(handler: StubHandler | None) None[source]

Install application-specific BUFR image handler.

Parameters:

handler – Handler object.

CurImagePlugin Module

class PIL.CurImagePlugin.CurImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: BmpImageFile

format: str | None = 'CUR'
format_description: str | None = 'Windows Cursor'

DcxImagePlugin Module

class PIL.DcxImagePlugin.DcxImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: PcxImageFile

format: str | None = 'DCX'
format_description: str | None = 'Intel DCX'
seek(frame: int) None[source]

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().

If defined, n_frames refers to the number of available frames.

Parameters:

frame – Frame number, starting at 0.

Raises:

EOFError – If the call attempts to seek beyond the end of the sequence.

tell() int[source]

Returns the current frame number. See seek().

If defined, n_frames refers to the number of available frames.

Returns:

Frame number, starting with 0.

DdsImagePlugin Module

A Pillow loader for .dds files (S3TC-compressed aka DXTC) Jerome Leclanche <jerome@leclan.ch>

Documentation: https://web.archive.org/web/20170802060935/http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_compression_s3tc.txt

The contents of this file are hereby released in the public domain (CC0) Full text of the CC0 license: https://creativecommons.org/publicdomain/zero/1.0/

class PIL.DdsImagePlugin.D3DFMT(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

A1 = 118
A16B16G16R16 = 36
A16B16G16R16F = 113
A1R5G5B5 = 25
A2B10G10R10 = 31
A2B10G10R10_XR_BIAS = 119
A2R10G10B10 = 35
A2W10V10U10 = 67
A32B32G32R32F = 116
A4L4 = 52
A4R4G4B4 = 26
A8 = 28
A8B8G8R8 = 32
A8L8 = 51
A8P8 = 40
A8R3G3B2 = 29
A8R8G8B8 = 21
ATI1 = 826889281
ATI2 = 843666497
BC4S = 1395934018
BC4U = 1429488450
BC5S = 1395999554
BC5U = 1429553986
BINARYBUFFER = 199
CxV8U8 = 117
D15S1 = 73
D16 = 80
D16_LOCKABLE = 70
D24FS8 = 83
D24S8 = 75
D24X4S4 = 79
D24X8 = 77
D32 = 71
D32F_LOCKABLE = 82
D32_LOCKABLE = 84
DX10 = 808540228
DXT1 = 827611204
DXT2 = 844388420
DXT3 = 861165636
DXT4 = 877942852
DXT5 = 894720068
G16R16 = 34
G16R16F = 112
G32R32F = 115
G8R8_G8B8 = 1111970375
INDEX16 = 101
INDEX32 = 102
L16 = 81
L6V5U5 = 61
L8 = 50
MULTI2_ARGB8 = 827606349
P8 = 41
Q16W16V16U16 = 110
Q8W8V8U8 = 63
R16F = 111
R32F = 114
R3G3B2 = 27
R5G6B5 = 23
R8G8B8 = 20
R8G8_B8G8 = 1195525970
S8_LOCKABLE = 85
UNKNOWN = 0
UYVY = 1498831189
V16U16 = 64
V8U8 = 60
VERTEXDATA = 100
X1R5G5B5 = 24
X4R4G4B4 = 30
X8B8G8R8 = 33
X8L8V8U8 = 62
X8R8G8B8 = 22
YUY2 = 844715353
class PIL.DdsImagePlugin.DDPF(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntFlag

ALPHA = 2
ALPHAPIXELS = 1
FOURCC = 4
LUMINANCE = 131072
PALETTEINDEXED8 = 32
RGB = 64
class PIL.DdsImagePlugin.DDSCAPS(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntFlag

COMPLEX = 8
MIPMAP = 4194304
TEXTURE = 4096
class PIL.DdsImagePlugin.DDSCAPS2(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntFlag

CUBEMAP = 512
CUBEMAP_NEGATIVEX = 2048
CUBEMAP_NEGATIVEY = 8192
CUBEMAP_NEGATIVEZ = 32768
CUBEMAP_POSITIVEX = 1024
CUBEMAP_POSITIVEY = 4096
CUBEMAP_POSITIVEZ = 16384
VOLUME = 2097152
class PIL.DdsImagePlugin.DDSD(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntFlag

CAPS = 1
DEPTH = 8388608
HEIGHT = 2
LINEARSIZE = 524288
MIPMAPCOUNT = 131072
PITCH = 8
PIXELFORMAT = 4096
WIDTH = 4
class PIL.DdsImagePlugin.DXGI_FORMAT(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

A8P8 = 114
A8_UNORM = 65
AI44 = 111
AYUV = 100
B4G4R4A4_UNORM = 115
B5G5R5A1_UNORM = 86
B5G6R5_UNORM = 85
B8G8R8A8_TYPELESS = 90
B8G8R8A8_UNORM = 87
B8G8R8A8_UNORM_SRGB = 91
B8G8R8X8_TYPELESS = 92
B8G8R8X8_UNORM = 88
B8G8R8X8_UNORM_SRGB = 93
BC1_TYPELESS = 70
BC1_UNORM = 71
BC1_UNORM_SRGB = 72
BC2_TYPELESS = 73
BC2_UNORM = 74
BC2_UNORM_SRGB = 75
BC3_TYPELESS = 76
BC3_UNORM = 77
BC3_UNORM_SRGB = 78
BC4_SNORM = 81
BC4_TYPELESS = 79
BC4_UNORM = 80
BC5_SNORM = 84
BC5_TYPELESS = 82
BC5_UNORM = 83
BC6H_SF16 = 96
BC6H_TYPELESS = 94
BC6H_UF16 = 95
BC7_TYPELESS = 97
BC7_UNORM = 98
BC7_UNORM_SRGB = 99
D16_UNORM = 55
D24_UNORM_S8_UINT = 45
D32_FLOAT = 40
D32_FLOAT_S8X24_UINT = 20
G8R8_G8B8_UNORM = 69
IA44 = 112
NV11 = 110
NV12 = 103
OPAQUE_420 = 106
P010 = 104
P016 = 105
P208 = 130
P8 = 113
R10G10B10A2_TYPELESS = 23
R10G10B10A2_UINT = 25
R10G10B10A2_UNORM = 24
R10G10B10_XR_BIAS_A2_UNORM = 89
R11G11B10_FLOAT = 26
R16G16B16A16_FLOAT = 10
R16G16B16A16_SINT = 14
R16G16B16A16_SNORM = 13
R16G16B16A16_TYPELESS = 9
R16G16B16A16_UINT = 12
R16G16B16A16_UNORM = 11
R16G16_FLOAT = 34
R16G16_SINT = 38
R16G16_SNORM = 37
R16G16_TYPELESS = 33
R16G16_UINT = 36
R16G16_UNORM = 35
R16_FLOAT = 54
R16_SINT = 59
R16_SNORM = 58
R16_TYPELESS = 53
R16_UINT = 57
R16_UNORM = 56
R1_UNORM = 66
R24G8_TYPELESS = 44
R24_UNORM_X8_TYPELESS = 46
R32G32B32A32_FLOAT = 2
R32G32B32A32_SINT = 4
R32G32B32A32_TYPELESS = 1
R32G32B32A32_UINT = 3
R32G32B32_FLOAT = 6
R32G32B32_SINT = 8
R32G32B32_TYPELESS = 5
R32G32B32_UINT = 7
R32G32_FLOAT = 16
R32G32_SINT = 18
R32G32_TYPELESS = 15
R32G32_UINT = 17
R32G8X24_TYPELESS = 19
R32_FLOAT = 41
R32_FLOAT_X8X24_TYPELESS = 21
R32_SINT = 43
R32_TYPELESS = 39
R32_UINT = 42
R8G8B8A8_SINT = 32
R8G8B8A8_SNORM = 31
R8G8B8A8_TYPELESS = 27
R8G8B8A8_UINT = 30
R8G8B8A8_UNORM = 28
R8G8B8A8_UNORM_SRGB = 29
R8G8_B8G8_UNORM = 68
R8G8_SINT = 52
R8G8_SNORM = 51
R8G8_TYPELESS = 48
R8G8_UINT = 50
R8G8_UNORM = 49
R8_SINT = 64
R8_SNORM = 63
R8_TYPELESS = 60
R8_UINT = 62
R8_UNORM = 61
R9G9B9E5_SHAREDEXP = 67
SAMPLER_FEEDBACK_MIN_MIP_OPAQUE = 189
SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE = 190
UNKNOWN = 0
V208 = 131
V408 = 132
X24_TYPELESS_G8_UINT = 47
X32_TYPELESS_G8X24_UINT = 22
Y210 = 108
Y216 = 109
Y410 = 101
Y416 = 102
YUY2 = 107
class PIL.DdsImagePlugin.DdsImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'DDS'
format_description: str | None = 'DirectDraw Surface'
load_seek(pos: int) None[source]
class PIL.DdsImagePlugin.DdsRgbDecoder(mode: str, *args: Any)[source]

Bases: PyDecoder

decode(buffer: bytes | SupportsArrayInterface) tuple[int, int][source]

Override to perform the decoding process.

Parameters:

buffer – A bytes object with the data to be decoded.

Returns:

A tuple of (bytes consumed, errcode). If finished with decoding return -1 for the bytes consumed. Err codes are from ImageFile.ERRORS.

EpsImagePlugin Module

class PIL.EpsImagePlugin.EpsImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

EPS File Parser for the Python Imaging Library

format: str | None = 'EPS'
format_description: str | None = 'Encapsulated Postscript'
load(scale: int = 1, transparency: bool = False) Image.core.PixelAccess | None[source]

Load image data based on tile list

load_seek(pos: int) None[source]
mode_map = {1: 'L', 2: 'LAB', 3: 'RGB', 4: 'CMYK'}
PIL.EpsImagePlugin.Ghostscript(tile: list[ImageFile._Tile], size: tuple[int, int], fp: IO[bytes], scale: int = 1, transparency: bool = False) Image.core.ImagingCore[source]

Render an image using Ghostscript

PIL.EpsImagePlugin.has_ghostscript() bool[source]

FitsImagePlugin Module

class PIL.FitsImagePlugin.FitsGzipDecoder(mode: str, *args: Any)[source]

Bases: PyDecoder

decode(buffer: bytes | SupportsArrayInterface) tuple[int, int][source]

Override to perform the decoding process.

Parameters:

buffer – A bytes object with the data to be decoded.

Returns:

A tuple of (bytes consumed, errcode). If finished with decoding return -1 for the bytes consumed. Err codes are from ImageFile.ERRORS.

class PIL.FitsImagePlugin.FitsImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'FITS'
format_description: str | None = 'FITS'

FliImagePlugin Module

class PIL.FliImagePlugin.FliImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'FLI'
format_description: str | None = 'Autodesk FLI/FLC Animation'
seek(frame: int) None[source]

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().

If defined, n_frames refers to the number of available frames.

Parameters:

frame – Frame number, starting at 0.

Raises:

EOFError – If the call attempts to seek beyond the end of the sequence.

tell() int[source]

Returns the current frame number. See seek().

If defined, n_frames refers to the number of available frames.

Returns:

Frame number, starting with 0.

FpxImagePlugin Module

class PIL.FpxImagePlugin.FpxImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

close() None[source]

Closes the file pointer, if possible.

This operation will destroy the image core and release its memory. The image data will be unusable afterward.

This function is required to close images that have multiple frames or have not had their file read and closed by the load() method. See File Handling in Pillow for more information.

format: str | None = 'FPX'
format_description: str | None = 'FlashPix'
load() Image.core.PixelAccess | None[source]

Load image data based on tile list

GbrImagePlugin Module

class PIL.GbrImagePlugin.GbrImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'GBR'
format_description: str | None = 'GIMP brush file'
load() Image.core.PixelAccess | None[source]

Load image data based on tile list

GifImagePlugin Module

class PIL.GifImagePlugin.GifImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

data() bytes | None[source]
format: str | None = 'GIF'
format_description: str | None = 'Compuserve GIF'
global_palette = None
property is_animated: bool
load_end() None[source]
load_prepare() None[source]
property n_frames: int
seek(frame: int) None[source]

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().

If defined, n_frames refers to the number of available frames.

Parameters:

frame – Frame number, starting at 0.

Raises:

EOFError – If the call attempts to seek beyond the end of the sequence.

tell() int[source]

Returns the current frame number. See seek().

If defined, n_frames refers to the number of available frames.

Returns:

Frame number, starting with 0.

PIL.GifImagePlugin.LOADING_STRATEGY = LoadingStrategy.RGB_AFTER_FIRST

Added in version 9.1.0.

class PIL.GifImagePlugin.LoadingStrategy(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Added in version 9.1.0.

RGB_AFTER_DIFFERENT_PALETTE_ONLY = 1
RGB_AFTER_FIRST = 0
RGB_ALWAYS = 2
PIL.GifImagePlugin.get_interlace(im: Image) int[source]
PIL.GifImagePlugin.getdata(im: Image, offset: tuple[int, int] = (0, 0), **params: Any) list[bytes][source]

Legacy Method

Return a list of strings representing this image. The first string is a local image header, the rest contains encoded image data.

To specify duration, add the time in milliseconds, e.g. getdata(im_frame, duration=1000)

Parameters:
  • im – Image object

  • offset – Tuple of (x, y) pixels. Defaults to (0, 0)

  • **params – e.g. duration or other encoder info parameters

Returns:

List of bytes containing GIF encoded frame data

PIL.GifImagePlugin.getheader(im: Image, palette: bytes | bytearray | list[int] | ImagePalette | None = None, info: dict[str, Any] | None = None) tuple[list[bytes], list[int] | None][source]

Legacy Method to get Gif data from image.

Warning:: May modify image data.

Parameters:
  • im – Image object

  • palette – bytes object containing the source palette, or ….

  • info – encoderinfo

Returns:

tuple of(list of header items, optimized palette)

GribStubImagePlugin Module

class PIL.GribStubImagePlugin.GribStubImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: StubImageFile

format: str | None = 'GRIB'
format_description: str | None = 'GRIB'
PIL.GribStubImagePlugin.register_handler(handler: StubHandler | None) None[source]

Install application-specific GRIB image handler.

Parameters:

handler – Handler object.

Hdf5StubImagePlugin Module

class PIL.Hdf5StubImagePlugin.HDF5StubImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: StubImageFile

format: str | None = 'HDF5'
format_description: str | None = 'HDF5'
PIL.Hdf5StubImagePlugin.register_handler(handler: StubHandler | None) None[source]

Install application-specific HDF5 image handler.

Parameters:

handler – Handler object.

IcnsImagePlugin Module

class PIL.IcnsImagePlugin.IcnsFile(fobj: IO[bytes])[source]

Bases: 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() tuple[int, int, int][source]
dataforsize(size: tuple[int, int, int]) dict[str, Image][source]

Get an icon resource as {channel: array}. Note that the arrays are bottom-up like windows bitmaps and will likely need to be flipped or transposed in some way.

getimage(size: tuple[int, int] | tuple[int, int, int] | None = None) Image[source]
itersizes() list[tuple[int, int, int]][source]
class PIL.IcnsImagePlugin.IcnsImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

PIL 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: str | None = 'ICNS'
format_description: str | None = 'Mac OS icns resource'
load(scale: int | None = None) Image.core.PixelAccess | None[source]

Load image data based on tile list

property size: tuple[int, int] | tuple[int, int, int]
PIL.IcnsImagePlugin.nextheader(fobj: IO[bytes]) tuple[bytes, int][source]
PIL.IcnsImagePlugin.read_32(fobj: IO[bytes], start_length: tuple[int, int], size: tuple[int, int, int]) dict[str, Image][source]

Read a 32bit RGB icon resource. Seems to be either uncompressed or an RLE packbits-like scheme.

PIL.IcnsImagePlugin.read_32t(fobj: IO[bytes], start_length: tuple[int, int], size: tuple[int, int, int]) dict[str, Image][source]
PIL.IcnsImagePlugin.read_mk(fobj: IO[bytes], start_length: tuple[int, int], size: tuple[int, int, int]) dict[str, Image][source]
PIL.IcnsImagePlugin.read_png_or_jpeg2000(fobj: IO[bytes], start_length: tuple[int, int], size: tuple[int, int, int]) dict[str, Image][source]

IcoImagePlugin Module

class PIL.IcoImagePlugin.IcoFile(buf: IO[bytes])[source]

Bases: object

frame(idx: int) Image[source]

Get an image from frame idx

getentryindex(size: tuple[int, int], bpp: int | bool = False) int[source]
getimage(size: tuple[int, int], bpp: int | bool = False) Image[source]

Get an image from the icon

sizes() set[tuple[int, int]][source]

Get a set of all available icon sizes and color depths.

class PIL.IcoImagePlugin.IcoImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

PIL 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. If you are unable to view the icon in Windows, convert the image to “RGBA” mode before saving.

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: str | None = 'ICO'
format_description: str | None = 'Windows Icon'
load() Image.core.PixelAccess | None[source]

Load image data based on tile list

load_seek(pos: int) None[source]
property size: tuple[int, int]
class PIL.IcoImagePlugin.IconHeader(width, height, nb_color, reserved, planes, bpp, size, offset, dim, square, color_depth)[source]

Bases: NamedTuple

bpp: int

Alias for field number 5

color_depth: int

Alias for field number 10

dim: tuple[int, int]

Alias for field number 8

height: int

Alias for field number 1

nb_color: int

Alias for field number 2

offset: int

Alias for field number 7

planes: int

Alias for field number 4

reserved: int

Alias for field number 3

size: int

Alias for field number 6

square: int

Alias for field number 9

width: int

Alias for field number 0

ImImagePlugin Module

class PIL.ImImagePlugin.ImImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'IM'
format_description: str | None = 'IFUNC Image Memory'
property is_animated: bool
property n_frames: int
seek(frame: int) None[source]

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().

If defined, n_frames refers to the number of available frames.

Parameters:

frame – Frame number, starting at 0.

Raises:

EOFError – If the call attempts to seek beyond the end of the sequence.

tell() int[source]

Returns the current frame number. See seek().

If defined, n_frames refers to the number of available frames.

Returns:

Frame number, starting with 0.

PIL.ImImagePlugin.number(s: Any) float[source]

ImtImagePlugin Module

class PIL.ImtImagePlugin.ImtImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'IMT'
format_description: str | None = 'IM Tools'

IptcImagePlugin Module

class PIL.IptcImagePlugin.IptcImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

field() tuple[tuple[int, int] | None, int][source]
format: str | None = 'IPTC'
format_description: str | None = 'IPTC/NAA'
getint(key: tuple[int, int]) int[source]
load() Image.core.PixelAccess | None[source]

Load image data based on tile list

PIL.IptcImagePlugin.dump(c: Sequence[int | bytes]) None[source]

Deprecated since version 10.2.0.

PIL.IptcImagePlugin.getiptcinfo(im: ImageFile) dict[tuple[int, int], bytes | list[bytes]] | None[source]

Get IPTC information from TIFF, JPEG, or IPTC file.

Parameters:

im – An image containing IPTC data.

Returns:

A dictionary containing IPTC information, or None if no IPTC information block was found.

PIL.IptcImagePlugin.i(c: bytes) int[source]

Deprecated since version 10.2.0.

JpegImagePlugin Module

PIL.JpegImagePlugin.APP(self: JpegImageFile, marker: int) None[source]
PIL.JpegImagePlugin.COM(self: JpegImageFile, marker: int) None[source]
PIL.JpegImagePlugin.DQT(self: JpegImageFile, marker: int) None[source]
class PIL.JpegImagePlugin.JpegImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

draft(mode: str | None, size: tuple[int, int] | None) tuple[str, tuple[int, int, float, float]] | None[source]

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 grayscale while loading it.

If any changes are made, returns a tuple with the chosen mode and box with coordinates of the original image within the altered one.

Note that this method modifies the Image object 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.

Parameters:
  • mode – The requested mode.

  • size – The requested size in pixels, as a 2-tuple: (width, height).

format: str | None = 'JPEG'
format_description: str | None = 'JPEG (ISO 10918)'
load_djpeg() None[source]
load_read(read_bytes: int) bytes[source]

internal: read more image data For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker so libjpeg can finish decoding

PIL.JpegImagePlugin.SOF(self: JpegImageFile, marker: int) None[source]
PIL.JpegImagePlugin.Skip(self: JpegImageFile, marker: int) None[source]
PIL.JpegImagePlugin.get_sampling(im: Image) int[source]
PIL.JpegImagePlugin.jpeg_factory(fp: IO[bytes], filename: str | bytes | None = None) JpegImageFile | MpoImageFile[source]

Jpeg2KImagePlugin Module

class PIL.Jpeg2KImagePlugin.BoxReader(fp: IO[bytes], length: int = -1)[source]

Bases: object

A small helper class to read fields stored in JPEG2000 header boxes and to easily step into and read sub-boxes.

has_next_box() bool[source]
next_box_type() bytes[source]
read_boxes() BoxReader[source]
read_fields(field_format: str) tuple[int | bytes, ...][source]
class PIL.Jpeg2KImagePlugin.Jpeg2KImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'JPEG2000'
format_description: str | None = 'JPEG 2000 (ISO 15444)'
load() Image.core.PixelAccess | None[source]

Load image data based on tile list

property reduce: Callable[[int | tuple[int, int], tuple[int, int, int, int] | None], Image] | int

Returns a copy of the image reduced factor times. If the size of the image is not dividable by factor, the resulting size will be rounded up.

Parameters:
  • factor – A greater than 0 integer or tuple of two integers for width and height separately.

  • box – An optional 4-tuple of ints providing the source image region to be reduced. The values must be within (0, 0, width, height) rectangle. If omitted or None, the entire source is used.

McIdasImagePlugin Module

class PIL.McIdasImagePlugin.McIdasImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'MCIDAS'
format_description: str | None = 'McIdas area file'

MicImagePlugin Module

class PIL.MicImagePlugin.MicImageFile(fp: str | bytes | PathLike[str] | PathLike[bytes] | IO[bytes], filename: str | bytes | None = None)[source]

Bases: TiffImageFile

close() None[source]

Closes the file pointer, if possible.

This operation will destroy the image core and release its memory. The image data will be unusable afterward.

This function is required to close images that have multiple frames or have not had their file read and closed by the load() method. See File Handling in Pillow for more information.

format: str | None = 'MIC'
format_description: str | None = 'Microsoft Image Composer'
seek(frame: int) None[source]

Select a given frame as current image

tell() int[source]

Return the current frame number

MpegImagePlugin Module

class PIL.MpegImagePlugin.BitStream(fp: SupportsRead[bytes])[source]

Bases: object

next() int[source]
peek(bits: int) int[source]
read(bits: int) int[source]
skip(bits: int) None[source]
class PIL.MpegImagePlugin.MpegImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'MPEG'
format_description: str | None = 'MPEG'

MpoImagePlugin Module

class PIL.MpoImagePlugin.MpoImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: JpegImageFile

static adopt(jpeg_instance: JpegImageFile, mpheader: dict[int, Any] | None = None) MpoImageFile[source]

Transform the instance of JpegImageFile into an instance of MpoImageFile. After the call, the JpegImageFile is extended to be an MpoImageFile.

This is essentially useful when opening a JPEG file that reveals itself as an MPO, to avoid double call to _open.

format: str | None = 'MPO'
format_description: str | None = 'MPO (CIPA DC-007)'
load_seek(pos: int) None[source]
seek(frame: int) None[source]

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().

If defined, n_frames refers to the number of available frames.

Parameters:

frame – Frame number, starting at 0.

Raises:

EOFError – If the call attempts to seek beyond the end of the sequence.

tell() int[source]

Returns the current frame number. See seek().

If defined, n_frames refers to the number of available frames.

Returns:

Frame number, starting with 0.

MspImagePlugin Module

class PIL.MspImagePlugin.MspDecoder(mode: str, *args: Any)[source]

Bases: PyDecoder

decode(buffer: bytes | SupportsArrayInterface) tuple[int, int][source]

Override to perform the decoding process.

Parameters:

buffer – A bytes object with the data to be decoded.

Returns:

A tuple of (bytes consumed, errcode). If finished with decoding return -1 for the bytes consumed. Err codes are from ImageFile.ERRORS.

class PIL.MspImagePlugin.MspImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'MSP'
format_description: str | None = 'Windows Paint'

PalmImagePlugin Module

PIL.PalmImagePlugin.build_prototype_image() Image[source]

PcdImagePlugin Module

class PIL.PcdImagePlugin.PcdImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'PCD'
format_description: str | None = 'Kodak PhotoCD'
load_end() None[source]

PcxImagePlugin Module

class PIL.PcxImagePlugin.PcxImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'PCX'
format_description: str | None = 'Paintbrush'

PdfImagePlugin Module

PixarImagePlugin Module

class PIL.PixarImagePlugin.PixarImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'PIXAR'
format_description: str | None = 'PIXAR raster image'

PngImagePlugin Module

class PIL.PngImagePlugin.Blend(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

OP_OVER = 1

This frame should be alpha composited with the previous output image contents. See Saving APNG sequences.

OP_SOURCE = 0

All color components of this frame, including alpha, overwrite the previous output image contents. See Saving APNG sequences.

class PIL.PngImagePlugin.ChunkStream(fp: IO[bytes])[source]

Bases: object

call(cid: bytes, pos: int, length: int) bytes[source]

Call the appropriate chunk handler

close() None[source]
crc(cid: bytes, data: bytes) None[source]

Read and verify checksum

crc_skip(cid: bytes, data: bytes) None[source]

Read checksum

push(cid: bytes, pos: int, length: int) None[source]
read() tuple[bytes, int, int][source]

Fetch a new chunk. Returns header information.

verify(endchunk: bytes = b'IEND') list[bytes][source]
class PIL.PngImagePlugin.Disposal(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

OP_BACKGROUND = 1

This frame’s modified region is cleared to fully transparent black before rendering the next frame. See Saving APNG sequences.

OP_NONE = 0

No disposal is done on this frame before rendering the next frame. See Saving APNG sequences.

OP_PREVIOUS = 2

This frame’s modified region is reverted to the previous frame’s contents before rendering the next frame. See Saving APNG sequences.

class PIL.PngImagePlugin.PngImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

getexif() Exif[source]

Gets EXIF data from the image.

Returns:

an Exif object.

load_end() None[source]

internal: finished reading image data

load_prepare() None[source]

internal: prepare to read PNG file

load_read(read_bytes: int) bytes[source]

internal: read more image data

seek(frame: int) None[source]

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().

If defined, n_frames refers to the number of available frames.

Parameters:

frame – Frame number, starting at 0.

Raises:

EOFError – If the call attempts to seek beyond the end of the sequence.

tell() int[source]

Returns the current frame number. See seek().

If defined, n_frames refers to the number of available frames.

Returns:

Frame number, starting with 0.

verify() None[source]

Verify PNG file

format: str | None = 'PNG'
format_description: str | None = 'Portable network graphics'
property text: dict[str, str | iTXt]
class PIL.PngImagePlugin.PngStream(fp: IO[bytes])[source]

Bases: ChunkStream

check_text_memory(chunklen: int) None[source]
chunk_IDAT(pos: int, length: int) NoReturn[source]
chunk_IEND(pos: int, length: int) NoReturn[source]
chunk_IHDR(pos: int, length: int) bytes[source]
chunk_PLTE(pos: int, length: int) bytes[source]
chunk_acTL(pos: int, length: int) bytes[source]
chunk_cHRM(pos: int, length: int) bytes[source]
chunk_eXIf(pos: int, length: int) bytes[source]
chunk_fcTL(pos: int, length: int) bytes[source]
chunk_fdAT(pos: int, length: int) bytes[source]
chunk_gAMA(pos: int, length: int) bytes[source]
chunk_iCCP(pos: int, length: int) bytes[source]
chunk_iTXt(pos: int, length: int) bytes[source]
chunk_pHYs(pos: int, length: int) bytes[source]
chunk_sRGB(pos: int, length: int) bytes[source]
chunk_tEXt(pos: int, length: int) bytes[source]
chunk_tRNS(pos: int, length: int) bytes[source]
chunk_zTXt(pos: int, length: int) bytes[source]
rewind() None[source]
save_rewind() None[source]
PIL.PngImagePlugin.getchunks(im: Image, **params: Any) list[tuple[bytes, bytes, bytes]][source]

Return a list of PNG chunks representing this image.

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

Matches zero or more characters at the beginning of the string.

PIL.PngImagePlugin.putchunk(fp: IO[bytes], cid: bytes, *data: bytes) None[source]

Write a PNG chunk (including CRC field)

PIL.PngImagePlugin.MAX_TEXT_CHUNK = 1048576

Maximum decompressed size for a iTXt or zTXt chunk. Eliminates decompression bombs where compressed chunks can expand 1000x. See Text in PNG File Format.

PIL.PngImagePlugin.MAX_TEXT_MEMORY = 67108864

Set the maximum total text chunk size. See Text in PNG File Format.

PpmImagePlugin Module

class PIL.PpmImagePlugin.PpmDecoder(mode: str, *args: Any)[source]

Bases: PyDecoder

decode(buffer: bytes | SupportsArrayInterface) tuple[int, int][source]

Override to perform the decoding process.

Parameters:

buffer – A bytes object with the data to be decoded.

Returns:

A tuple of (bytes consumed, errcode). If finished with decoding return -1 for the bytes consumed. Err codes are from ImageFile.ERRORS.

class PIL.PpmImagePlugin.PpmImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'PPM'
format_description: str | None = 'Pbmplus image'
class PIL.PpmImagePlugin.PpmPlainDecoder(mode: str, *args: Any)[source]

Bases: PyDecoder

decode(buffer: bytes | SupportsArrayInterface) tuple[int, int][source]

Override to perform the decoding process.

Parameters:

buffer – A bytes object with the data to be decoded.

Returns:

A tuple of (bytes consumed, errcode). If finished with decoding return -1 for the bytes consumed. Err codes are from ImageFile.ERRORS.

PsdImagePlugin Module

class PIL.PsdImagePlugin.PsdImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'PSD'
format_description: str | None = 'Adobe Photoshop'
property is_animated: bool
property layers: list[tuple[str, str, tuple[int, int, int, int], list[_Tile]]]
property n_frames: int
seek(layer: int) None[source]

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().

If defined, n_frames refers to the number of available frames.

Parameters:

frame – Frame number, starting at 0.

Raises:

EOFError – If the call attempts to seek beyond the end of the sequence.

tell() int[source]

Returns the current frame number. See seek().

If defined, n_frames refers to the number of available frames.

Returns:

Frame number, starting with 0.

SgiImagePlugin Module

class PIL.SgiImagePlugin.SGI16Decoder(mode: str, *args: Any)[source]

Bases: PyDecoder

decode(buffer: bytes | SupportsArrayInterface) tuple[int, int][source]

Override to perform the decoding process.

Parameters:

buffer – A bytes object with the data to be decoded.

Returns:

A tuple of (bytes consumed, errcode). If finished with decoding return -1 for the bytes consumed. Err codes are from ImageFile.ERRORS.

class PIL.SgiImagePlugin.SgiImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'SGI'
format_description: str | None = 'SGI Image File Format'

SpiderImagePlugin Module

class PIL.SpiderImagePlugin.SpiderImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

convert2byte(depth: int = 255) Image[source]
format: str | None = 'SPIDER'
format_description: str | None = 'Spider 2D image'
property is_animated: bool
property n_frames: int
seek(frame: int) None[source]

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().

If defined, n_frames refers to the number of available frames.

Parameters:

frame – Frame number, starting at 0.

Raises:

EOFError – If the call attempts to seek beyond the end of the sequence.

tell() int[source]

Returns the current frame number. See seek().

If defined, n_frames refers to the number of available frames.

Returns:

Frame number, starting with 0.

tkPhotoImage() ImageTk.PhotoImage[source]
PIL.SpiderImagePlugin.isInt(f: Any) int[source]
PIL.SpiderImagePlugin.isSpiderHeader(t: tuple[float, ...]) int[source]
PIL.SpiderImagePlugin.isSpiderImage(filename: str) int[source]
PIL.SpiderImagePlugin.loadImageSeries(filelist: list[str] | None = None) list[SpiderImageFile] | None[source]

create a list of Image objects for use in a montage

PIL.SpiderImagePlugin.makeSpiderHeader(im: Image) list[bytes][source]

SunImagePlugin Module

class PIL.SunImagePlugin.SunImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'SUN'
format_description: str | None = 'Sun Raster File'

TgaImagePlugin Module

class PIL.TgaImagePlugin.TgaImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'TGA'
format_description: str | None = 'Targa'
load_end() None[source]

TiffImagePlugin Module

class PIL.TiffImagePlugin.AppendingTiffWriter(fn: str | bytes | PathLike[str] | PathLike[bytes] | IO[bytes], new: bool = False)[source]

Bases: BytesIO

Tags = {273, 288, 324, 519, 520, 521}
close() None[source]

Disable all I/O operations.

fieldSizes = [0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4, 2, 4, 8]
finalize() None[source]
fixIFD() None[source]
fixOffsets(count: int, isShort: bool = False, isLong: bool = False) None[source]
goToEnd() None[source]
newFrame() None[source]
readLong() int[source]
readShort() int[source]
rewriteLastLong(value: int) None[source]
rewriteLastShort(value: int) None[source]
rewriteLastShortToLong(value: int) None[source]
seek(offset: int, whence: int = 0) int[source]
Parameters:
  • offset – Distance to seek.

  • whence – Whether the distance is relative to the start, end or current position.

Returns:

The resulting position, relative to the start.

setEndian(endian: str) None[source]
setup() None[source]
skipIFDs() None[source]
tell() int[source]

Current file position, an integer.

write(data: Buffer, /) int[source]

Write bytes to file.

Return the number of bytes written.

writeLong(value: int) None[source]
writeShort(value: int) None[source]
class PIL.TiffImagePlugin.IFDRational(value: float | Fraction | IFDRational, denominator: int = 1)[source]

Bases: Rational

Implements 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: int
limit_rational(max_denominator: int) tuple[IntegralLike, int][source]
Parameters:

max_denominator – Integer, the maximum denominator value

Returns:

Tuple of (numerator, denominator)

property numerator: IntegralLike
PIL.TiffImagePlugin.ImageFileDirectory

alias of ImageFileDirectory_v1

class PIL.TiffImagePlugin.ImageFileDirectory_v1(*args: Any, **kwargs: Any)[source]

Bases: ImageFileDirectory_v2

This 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, tagtype.

Values are returned as a tuple.

Deprecated since version 3.0.0.

classmethod from_v2(original: ImageFileDirectory_v2) ImageFileDirectory_v1[source]

Returns an ImageFileDirectory_v1 instance with the same data as is contained in the original ImageFileDirectory_v2 instance.

Returns:

ImageFileDirectory_v1

property tagdata
property tags
tagtype: dict[int, int]

Dictionary of tag types

to_v2() ImageFileDirectory_v2[source]

Returns an ImageFileDirectory_v2 instance with the same data as is contained in the original ImageFileDirectory_v1 instance.

Returns:

ImageFileDirectory_v2

class PIL.TiffImagePlugin.ImageFileDirectory_v2(ifh: bytes = b'II*\x00\x00\x00\x00\x00', prefix: bytes | None = None, group: int | None = None)[source]

Bases: MutableMapping

This 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 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 TiffTags.TYPES

    Added in version 3.0.0.

‘Internal’ data structures:

  • self._tags_v2 = {}

    • Key: numerical TIFF tag number

    • Value: decoded data, as tuple for multiple values

  • self._tagdata = {}

    • Key: numerical TIFF tag number

    • Value: undecoded byte string from file

  • self._tags_v1 = {}

    • Key: numerical TIFF tag number

    • Value: decoded data in the v1 format

Tags will be found in the private attributes self._tagdata, and in self._tags_v2 once decoded.

self.legacy_api is a value for internal use, and shouldn’t be changed from outside code. In cooperation with ImageFileDirectory_v1, if legacy_api is true, then decoded tags will be populated into both _tags_v1 and _tags_v2. _tags_v2 will be used if this IFD is used in the TIFF save routine. Tags should be read from _tags_v1 if legacy_api == true.

property legacy_api: bool
load(fp: IO[bytes]) None[source]
load_byte(data: bytes, legacy_api: bool = True) bytes[source]
load_double(data: bytes, legacy_api: bool = True) tuple[Any, ...]
load_float(data: bytes, legacy_api: bool = True) tuple[Any, ...]
load_long(data: bytes, legacy_api: bool = True) tuple[Any, ...]
load_long8(data: bytes, legacy_api: bool = True) tuple[Any, ...]
load_rational(data: bytes, legacy_api: bool = True) tuple[tuple[int, int] | IFDRational, ...][source]
load_short(data: bytes, legacy_api: bool = True) tuple[Any, ...]
load_signed_byte(data: bytes, legacy_api: bool = True) tuple[Any, ...]
load_signed_long(data: bytes, legacy_api: bool = True) tuple[Any, ...]
load_signed_rational(data: bytes, legacy_api: bool = True) tuple[tuple[int, int] | IFDRational, ...][source]
load_signed_short(data: bytes, legacy_api: bool = True) tuple[Any, ...]
load_string(data: bytes, legacy_api: bool = True) str[source]
load_undefined(data: bytes, legacy_api: bool = True) bytes[source]
named() dict[str, Any][source]
Returns:

dict of name|key: value

Returns the complete tag dictionary, with named tags where possible.

property offset
property prefix
reset() None[source]
save(fp: IO[bytes]) int[source]
tagtype: dict[int, int]

Dictionary of tag types

tobytes(offset: int = 0) bytes[source]
write_byte(data: bytes | int | IFDRational) bytes[source]
write_double(*values)
write_float(*values)
write_long(*values)
write_long8(*values)
write_rational(*values: IFDRational) bytes[source]
write_short(*values)
write_signed_byte(*values)
write_signed_long(*values)
write_signed_rational(*values: IFDRational) bytes[source]
write_signed_short(*values)
write_string(value: str | bytes | int) bytes[source]
write_undefined(value: bytes | int | IFDRational) bytes[source]
class PIL.TiffImagePlugin.TiffImageFile(fp: str | bytes | PathLike[str] | PathLike[bytes] | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'TIFF'
format_description: str | None = 'Adobe TIFF'
get_photoshop_blocks() dict[int, dict[str, bytes]][source]

Returns a dictionary of Photoshop “Image Resource Blocks”. The keys are the image resource ID. For more information, see https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_pgfId-1037727

Returns:

Photoshop “Image Resource Blocks” in a dictionary.

load() Image.core.PixelAccess | None[source]

Load image data based on tile list

load_end() None[source]
load_prepare() None[source]
property n_frames: int
seek(frame: int) None[source]

Select a given frame as current image

tag: ImageFileDirectory_v1

Legacy tag entries

tag_v2: ImageFileDirectory_v2

Image file directory (tag dictionary)

tell() int[source]

Return the current frame number

WebPImagePlugin Module

class PIL.WebPImagePlugin.WebPImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'WEBP'
format_description: str | None = 'WebP image'
load() Image.core.PixelAccess | None[source]

Load image data based on tile list

load_seek(pos: int) None[source]
seek(frame: int) None[source]

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().

If defined, n_frames refers to the number of available frames.

Parameters:

frame – Frame number, starting at 0.

Raises:

EOFError – If the call attempts to seek beyond the end of the sequence.

tell() int[source]

Returns the current frame number. See seek().

If defined, n_frames refers to the number of available frames.

Returns:

Frame number, starting with 0.

WmfImagePlugin Module

class PIL.WmfImagePlugin.WmfStubImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: StubImageFile

format: str | None = 'WMF'
format_description: str | None = 'Windows Metafile'
load(dpi: int | None = None) Image.core.PixelAccess | None[source]

Load image data based on tile list

PIL.WmfImagePlugin.register_handler(handler: StubHandler | None) None[source]

Install application-specific WMF image handler.

Parameters:

handler – Handler object.

XVThumbImagePlugin Module

class PIL.XVThumbImagePlugin.XVThumbImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'XVThumb'
format_description: str | None = 'XV thumbnail image'

XbmImagePlugin Module

class PIL.XbmImagePlugin.XbmImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'XBM'
format_description: str | None = 'X11 Bitmap'

XpmImagePlugin Module

class PIL.XpmImagePlugin.XpmImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[source]

Bases: ImageFile

format: str | None = 'XPM'
format_description: str | None = 'X11 Pixel Map'
load_read(read_bytes: int) bytes[source]