PIL package (autodoc of remaining modules)

Reference for modules whose documentation has not yet been ported or written can be found here.

PIL module

exception PIL.UnidentifiedImageError[source]

Bases: OSError

Raised in PIL.Image.open() if an image cannot be opened and identified.

If a PNG image raises this error, setting ImageFile.LOAD_TRUNCATED_IMAGES to true may allow the image to be opened after all. The setting will ignore missing data and checksum failures.

BdfFontFile module

ContainerIO module

class PIL.ContainerIO.ContainerIO(file: IO, offset: int, length: int)[source]

Bases: IO

A file object that provides read access to a part of an existing file (for example a TAR file).

close() None[source]
fileno() int[source]
flush() None[source]
isatty() bool[source]
read(n: int = -1) AnyStr[source]

Read data.

Parameters:

n – Number of bytes to read. If omitted, zero or negative, read until end of region.

Returns:

An 8-bit string.

readable() bool[source]
readline(n: int = -1) AnyStr[source]

Read a line of text.

Parameters:

n – Number of bytes to read. If omitted, zero or negative, read until end of line.

Returns:

An 8-bit string.

readlines(n: int | None = -1) list[AnyStr][source]

Read multiple lines of text.

Parameters:

n – Number of lines to read. If omitted, zero, negative or None, read until end of region.

Returns:

A list of 8-bit strings.

seek(offset: int, mode: int = 0) int[source]

Move file pointer.

Parameters:
  • offset – Offset in bytes.

  • mode – Starting position. Use 0 for beginning of region, 1 for current offset, and 2 for end of region. You cannot move the pointer outside the defined region.

Returns:

Offset from start of region, in bytes.

seekable() bool[source]
tell() int[source]

Get current file pointer.

Returns:

Offset from start of region, in bytes.

truncate(size: int | None = None) int[source]
writable() bool[source]
write(b: AnyStr) NoReturn[source]
writelines(lines: Iterable) NoReturn[source]

FontFile module

GdImageFile module

GimpGradientFile module

Stuff to translate curve segments to palette values (derived from the corresponding code in GIMP, written by Federico Mena Quintero. See the GIMP distribution for more information.)

PIL.GimpGradientFile.EPSILON = 1e-10
class PIL.GimpGradientFile.GimpGradientFile(fp: IO[bytes])[source]

Bases: GradientFile

File handler for GIMP’s gradient format.

class PIL.GimpGradientFile.GradientFile[source]

Bases: object

getpalette(entries: int = 256) tuple[bytes, str][source]
gradient: list[tuple[float, float, float, list[float], list[float], Callable[[float, float], float]]] | None = None
PIL.GimpGradientFile.SEGMENTS = [<function linear>, <function curved>, <function sine>, <function sphere_increasing>, <function sphere_decreasing>]
PIL.GimpGradientFile.curved(middle: float, pos: float) float[source]
PIL.GimpGradientFile.linear(middle: float, pos: float) float[source]
PIL.GimpGradientFile.sine(middle: float, pos: float) float[source]
PIL.GimpGradientFile.sphere_decreasing(middle: float, pos: float) float[source]
PIL.GimpGradientFile.sphere_increasing(middle: float, pos: float) float[source]

GimpPaletteFile module

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

Bases: object

File handler for GIMP’s palette format.

classmethod frombytes(data: bytes) GimpPaletteFile[source]
getpalette() tuple[bytes, str][source]
rawmode = 'RGB'

ImageDraw2 module

ImageMode module

class PIL.ImageMode.ModeDescriptor(mode: str, bands: tuple[str, ...], basemode: str, basetype: str, typestr: str)[source]

Bases: NamedTuple

Wrapper for mode strings.

bands: tuple[str, ...]

Alias for field number 1

basemode: str

Alias for field number 2

basetype: str

Alias for field number 3

mode: str

Alias for field number 0

typestr: str

Alias for field number 4

PIL.ImageMode.getmode(mode: str) ModeDescriptor[source]

Gets a mode descriptor for the given mode.

PaletteFile module

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

Bases: object

File handler for Teragon-style palette files.

getpalette() tuple[bytes, str][source]
rawmode = 'RGB'

PcfFontFile module

PngImagePlugin.iTXt class

PngImagePlugin.PngInfo class

TarIO module

class PIL.TarIO.TarIO(tarfile: str, file: str)[source]

Bases: ContainerIO[bytes]

A file object that provides read access to a given member of a TAR file.

WalImageFile module