PIL Package (autodoc of remaining modules)

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

BdfFontFile Module

class PIL.BdfFontFile.BdfFontFile(fp)[source]

Bases: PIL.FontFile.FontFile

PIL.BdfFontFile.bdf_char(f)[source]

ContainerIO Module

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

Bases: object

isatty()[source]
read(n=0)[source]

Read data.

Parameters:n – Number of bytes to read. If omitted or zero, read until end of region.
Returns:An 8-bit string.
readline()[source]

Read a line of text.

Returns:An 8-bit string.
readlines()[source]

Read multiple lines of text.

Returns:A list of 8-bit strings.
seek(offset, mode=0)[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.
tell()[source]

Get current file pointer.

Returns:Offset from start of region, in bytes.

FontFile Module

class PIL.FontFile.FontFile[source]

Bases: object

bitmap = None
compile()[source]

Create metrics and bitmap

save(filename)[source]

Save font

PIL.FontFile.puti16(fp, values)[source]

GdImageFile Module

class PIL.GdImageFile.GdImageFile(fp=None, filename=None)[source]

Bases: PIL.ImageFile.ImageFile

format = 'GD'
format_description = 'GD uncompressed images'
PIL.GdImageFile.open(fp, mode='r')[source]

Load texture from a GD image file.

Parameters:
  • filename – GD file name, or an opened file handle.
  • mode – Optional mode. In this version, if the mode argument is given, it must be “r”.
Returns:

An image instance.

Raises:

IOError – If the image could not be read.

GimpGradientFile Module

class PIL.GimpGradientFile.GimpGradientFile(fp)[source]

Bases: PIL.GimpGradientFile.GradientFile

class PIL.GimpGradientFile.GradientFile[source]

Bases: object

getpalette(entries=256)[source]
gradient = None
PIL.GimpGradientFile.curved(middle, pos)[source]
PIL.GimpGradientFile.linear(middle, pos)[source]
PIL.GimpGradientFile.sine(middle, pos)[source]
PIL.GimpGradientFile.sphere_decreasing(middle, pos)[source]
PIL.GimpGradientFile.sphere_increasing(middle, pos)[source]

GimpPaletteFile Module

class PIL.GimpPaletteFile.GimpPaletteFile(fp)[source]

Bases: object

getpalette()[source]
rawmode = 'RGB'

ImageDraw2 Module

class PIL.ImageDraw2.Brush(color, opacity=255)[source]

Bases: object

class PIL.ImageDraw2.Draw(image, size=None, color=None)[source]

Bases: object

arc(xy, start, end, *options)[source]
chord(xy, start, end, *options)[source]
ellipse(xy, *options)[source]
flush()[source]
line(xy, *options)[source]
pieslice(xy, start, end, *options)[source]
polygon(xy, *options)[source]
rectangle(xy, *options)[source]
render(op, xy, pen, brush=None)[source]
settransform(offset)[source]
symbol(xy, symbol, *options)[source]
text(xy, text, font)[source]
textsize(text, font)[source]
class PIL.ImageDraw2.Font(color, file, size=12)[source]

Bases: object

class PIL.ImageDraw2.Pen(color, width=1, opacity=255)[source]

Bases: object

ImageShow Module

class PIL.ImageShow.DisplayViewer[source]

Bases: PIL.ImageShow.UnixViewer

get_command_ex(file, **options)[source]
class PIL.ImageShow.EogViewer[source]

Bases: PIL.ImageShow.UnixViewer

get_command_ex(file, **options)[source]
class PIL.ImageShow.UnixViewer[source]

Bases: PIL.ImageShow.Viewer

format = 'PNG'
options = {'compress_level': 1}
show_file(file, **options)[source]
class PIL.ImageShow.Viewer[source]

Bases: object

Base class for viewers.

format = None
get_command(file, **options)[source]
get_format(image)[source]

Return format name, or None to save as PGM/PPM

options = {}
save_image(image)[source]

Save to temporary file, and return filename

show(image, **options)[source]
show_file(file, **options)[source]

Display given file

show_image(image, **options)[source]

Display given image

class PIL.ImageShow.XVViewer[source]

Bases: PIL.ImageShow.UnixViewer

get_command_ex(file, title=None, **options)[source]
PIL.ImageShow.register(viewer, order=1)[source]
PIL.ImageShow.show(image, title=None, **options)[source]

Display a given image.

Parameters:
  • image – An image object.
  • title – Optional title. Not all viewers can display the title.
  • **options – Additional viewer options.
Returns:

True if a suitable viewer was found, false otherwise.

PIL.ImageShow.which(executable)[source]

ImageTransform Module

class PIL.ImageTransform.AffineTransform(data)[source]

Bases: PIL.ImageTransform.Transform

Define 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.
method = 0
class PIL.ImageTransform.ExtentTransform(data)[source]

Bases: PIL.ImageTransform.Transform

Define 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.
method = 1
class PIL.ImageTransform.MeshTransform(data)[source]

Bases: PIL.ImageTransform.Transform

Define a mesh image tran