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:
OSErrorRaised in
PIL.Image.open()if an image cannot be opened and identified.If a PNG image raises this error, setting
ImageFile.LOAD_TRUNCATED_IMAGESto true may allow the image to be opened after all. The setting will ignore missing data and checksum failures.
BdfFontFile Module¶
Parse X Bitmap Distribution Format (BDF)
ContainerIO Module¶
- class PIL.ContainerIO.ContainerIO(file: IO, offset: int, length: int)[source]¶
Bases:
GenericA file object that provides read access to a part of an existing file (for example a TAR file).
- read(n: int = 0) AnyStr[source]¶
Read data.
- Parameters:
n – Number of bytes to read. If omitted or zero, read until end of region.
- Returns:
An 8-bit string.
FontFile Module¶
GdImageFile Module¶
Note
This format cannot be automatically recognized, so the
class is not registered for use with PIL.Image.open(). To open a
gd file, use the PIL.GdImageFile.open() function instead.
Warning
THE GD FORMAT IS NOT DESIGNED FOR DATA INTERCHANGE. This implementation is provided for convenience and demonstrational purposes only.
- class PIL.GdImageFile.GdImageFile(fp=None, filename=None)[source]¶
Bases:
ImageFileImage plugin for the GD uncompressed format. Note that this format is not supported by the standard
PIL.Image.open()function. To use this plugin, you have to import thePIL.GdImageFilemodule and use thePIL.GdImageFile.open()function.- format: str | None = 'GD'¶
- format_description: str | None = 'GD uncompressed images'¶
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)[source]¶
Bases:
GradientFileFile handler for GIMP’s gradient format.
- PIL.GimpGradientFile.SEGMENTS = [<function linear>, <function curved>, <function sine>, <function sphere_increasing>, <function sphere_decreasing>]¶
GimpPaletteFile Module¶
ImageDraw2 Module¶
(Experimental) WCK-style drawing interface operations
See also
- class PIL.ImageDraw2.Pen(color, width=1, opacity=255)[source]¶
Bases:
objectStores an outline color and width.
- class PIL.ImageDraw2.Font(color, file, size=12)[source]¶
Bases:
objectStores a TrueType font and color
- class PIL.ImageDraw2.Draw(image, size=None, color=None)[source]¶
Bases:
object(Experimental) WCK-style drawing interface
- arc(xy, start, end, *options)[source]¶
Draws an arc (a portion of a circle outline) between the start and end angles, inside the given bounding box.
See also
- chord(xy, start, end, *options)[source]¶
Same as
arc(), but connects the end points with a straight line.See also
- pieslice(xy, start, end, *options)[source]¶
Same as arc, but also draws straight lines between the end points and the center of the bounding box.
See also
- polygon(xy, *options)[source]¶
Draws a polygon.
The polygon outline consists of straight lines between the given coordinates, plus a straight line between the last and the first coordinate.
See also
- textbbox(xy, text, font)[source]¶
Returns bounding box (in pixels) of given text.
- Returns:
(left, top, right, bottom)bounding box
See also
ImageMode Module¶
- class PIL.ImageMode.ModeDescriptor(mode: str, bands: tuple[str, ...], basemode: str, basetype: str, typestr: str)[source]¶
Bases:
objectWrapper for mode strings.
- PIL.ImageMode.getmode(mode: str) ModeDescriptor[source]¶
Gets a mode descriptor for the given mode.
ImageTransform Module¶
- class PIL.ImageTransform.AffineTransform(data: Sequence[int])[source]¶
Bases:
TransformDefine an affine image transform.
This function takes a 6-tuple (a, b, c, d, e, f) which contain the first two rows from an affine transform matrix. For each pixel (x, y) in the output image, the new value is taken from a position (a x + b y + c, d x + e y + f) in the input image, rounded to nearest pixel.
This function can be used to scale, translate, rotate, and shear the original image.
See
transform()- Parameters:
matrix – A 6-tuple (a, b, c, d, e, f) containing the first two rows from an affine transform matrix.
- class PIL.ImageTransform.ExtentTransform(data: Sequence[int])[source]¶
Bases:
TransformDefine a transform to extract a subregion from an image.
Maps a rectangle (defined by two corners) from the image to a rectangle of the given size. The resulting image will contain data sampled from between the corners, such that (x0, y0) in the input image will end up at (0,0) in the output image, and (x1, y1) at size.
This method can be used to crop, stretch, shrink, or mirror an arbitrary rectangle in the current image. It is slightly slower than crop, but about as fast as a corresponding resize operation.
See
transform()- Parameters:
bbox – A 4-tuple (x0, y0, x1, y1) which specifies two points in the input image’s coordinate system. See Coordinate System.
- class PIL.ImageTransform.MeshTransform(data: Sequence[int])[source]¶
Bases:
TransformDefine a mesh image transform. A mesh transform consists of one or more individual quad transforms.
See
transform()- Parameters:
data – A list of (bbox, quad) tuples.
- class PIL.ImageTransform.QuadTransform(data: Sequence[int])[source]¶
Bases:
TransformDefine a quad image transform.
Maps a quadrilateral (a region defined by four corners) from the image to a rectangle of the given size.
See
transform()- Parameters:
xy – An 8-tuple (x0, y0, x1, y1, x2, y2, x3, y3) which contain the upper left, lower left, lower right, and upper right corner of the source quadrilateral.
PaletteFile Module¶
PcfFontFile Module¶
PngImagePlugin.iTXt Class¶
PngImagePlugin.PngInfo Class¶
- class PIL.PngImagePlugin.PngInfo[source]¶
Bases:
objectPNG chunk container (for use with save(pnginfo=))
- add(cid, data, after_idat=False)[source]¶
Appends an arbitrary chunk. Use with caution.
- Parameters:
cid – a byte string, 4 bytes long.
data – a byte string of the encoded data
after_idat – for use with private chunks. Whether the chunk should be written after IDAT
- add_itxt(key, value, lang='', tkey='', zip=False)[source]¶
Appends an iTXt chunk.
- Parameters:
key – latin-1 encodable text key name
value – value for this key
lang – language code
tkey – UTF-8 version of the key name
zip – compression flag
- add_text(key, value, zip=False)[source]¶
Appends a text chunk.
- Parameters:
key – latin-1 encodable text key name
value – value for this key, text or an
PIL.PngImagePlugin.iTXtinstancezip – compression flag
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¶
This reader is based on the specification available from: https://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml and has been tested with a few sample files found using google.
Note
This format cannot be automatically recognized, so the reader
is not registered for use with PIL.Image.open().
To open a WAL file, use the PIL.WalImageFile.open() function instead.
- class PIL.WalImageFile.WalImageFile(fp=None, filename=None)[source]¶
Bases:
ImageFile- format: str | None = 'WAL'¶
- format_description: str | None = 'Quake2 Texture'¶
- PIL.WalImageFile.open(filename)[source]¶
Load texture from a Quake2 WAL texture file.
By default, a Quake2 standard palette is attached to the texture. To override the palette, use the
PIL.Image.Image.putpalette()method.- Parameters:
filename – WAL file name, or an opened file handle.
- Returns:
An image instance.