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]
isatty()[source]
read(n=0)[source]
readline()[source]
readlines()[source]
seek(offset, mode=0)[source]
tell()[source]

ExifTags Module

FontFile Module

class PIL.FontFile.FontFile[source]
bitmap = None
compile()[source]

Create metrics and bitmap

save(filename)

Save font in version 1 format

save1(filename)[source]

Save font in version 1 format

save2(filename)[source]

Save font in version 2 format

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]

GimpGradientFile Module

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

Bases: PIL.GimpGradientFile.GradientFile

class PIL.GimpGradientFile.GradientFile[source]
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]
getpalette()[source]
rawmode = 'RGB'

ImageCms Module

ImageDraw2 Module

class PIL.ImageDraw2.Brush(color, opacity=255)[source]
class PIL.ImageDraw2.Draw(image, size=None, color=None)[source]
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]
class PIL.ImageDraw2.Pen(color, width=1, opacity=255)[source]

ImageFileIO Module

The ImageFileIO module can be used to read an image from a socket, or any other stream device.

Deprecated. New code should use the PIL.ImageFile.Parser class in the PIL.ImageFile module instead.

See also

modules PIL.ImageFile.Parser

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

Bases: _io.BytesIO

ImageShow Module

class PIL.ImageShow.DisplayViewer[source]

Bases: PIL.ImageShow.UnixViewer

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

Bases: PIL.ImageShow.Viewer

show_file(file, **options)[source]
class PIL.ImageShow.Viewer[source]
format = None
get_command(file, **options)[source]
get_format(image)[source]
save_image(image)[source]
show(image, **options)[source]
show_file(file, **options)[source]
show_image(image, **options)[source]
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]
PIL.ImageShow.which(executable)[source]

ImageTransform Module

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

Bases: PIL.ImageTransform.Transform

method = 0
class PIL.ImageTransform.ExtentTransform(data)[source]

Bases: PIL.ImageTransform.Transform

method = 1
class PIL.ImageTransform.MeshTransform(data)[source]

Bases: PIL.ImageTransform.Transform

method = 4
class PIL.ImageTransform.QuadTransform(data)[source]

Bases: PIL.ImageTransform.Transform

method = 3
class PIL.ImageTransform.Transform(data)[source]

Bases: PIL.Image.ImageTransformHandler

getdata()[source]
transform(size, image, **options)[source]

JpegPresets Module

JPEG quality settings equivalent to the Photoshop settings.

More presets can be added to the presets dict if needed.

Can be use when saving JPEG file.

To apply the preset, specify:

quality="preset_name"

To apply only the quantization table:

qtables="preset_name"

To apply only the subsampling setting:

subsampling="preset_name"

Example:

im.save("image_name.jpg", quality="web_high")

Subsampling

Subsampling is the practice of encoding images by implementing less resolution for chroma information than for luma information. (ref.: http://en.wikipedia.org/wiki/Chroma_subsampling)

Possible subsampling values are 0, 1 and 2 that correspond to 4:4:4, 4:2:2 and 4:1:1 (or 4:2:0?).

You can get the subsampling of a JPEG with the JpegImagePlugin.get_subsampling(im) function.

Quantization tables

They are values use by the DCT (Discrete cosine transform) to remove unnecessary information from the image (the lossy part of the compression). (ref.: http://en.wikipedia.org/wiki/Quantization_matrix#Quantization_matrices, http://en.wikipedia.org/wiki/JPEG#Quantization)

You can get the quantization tables of a JPEG with:

im.quantization

This will return a dict with a number of arrays. You can pass this dict directly as the qtables argument when saving a JPEG.

The tables format between im.quantization and quantization in presets differ in 3 ways:

  1. The base container of the preset is a list with sublists instead of dict. dict[0] -> list[0], dict[1] -> list[1], ...
  2. Each table in a preset is a list instead of an array.
  3. The zigzag order is remove in the preset (needed by libjpeg >= 6a).

You can convert the dict format to the preset format with the JpegImagePlugin.convert_dict_qtables(dict_qtables) function.

Libjpeg ref.: http://www.jpegcameras.com/libjpeg/libjpeg-3.html

OleFileIO Module

class PIL.OleFileIO.OleFileIO(filename=None)[source]

OLE container object

This class encapsulates the interface to an OLE 2 structured storage file. Use the listdir and openstream methods to access the contents of this file.

Object names are given as a list of strings, one for each subentry level. The root entry should be omitted. For example, the following code extracts all image streams from a Microsoft Image Composer file:

ole = OleFileIO("fan.mic")

for entry in ole.listdir():
    if entry[1:2] == "Image":
        fin = ole.openstream(entry)
        fout = open(entry[0:1], "wb")
        while 1:
            s = fin.read(8192)
            if not s:
                break
            fout.write(s)

You can use the viewer application provided with the Python Imaging Library to view the resulting files (which happens to be standard TIFF files).

dumpdirectory()[source]
getproperties(filename)[source]

Return properties described in substream

getsect(sect)[source]
listdir()[source]

Return a list of streams stored in this file

loaddirectory(sect)[source]
loadfat(header)[source]
loadminifat()[source]
open(filename)[source]

Open an OLE2 file

openstream(filename)[source]

Open a stream as a read-only file object

PaletteFile Module

class PIL.PaletteFile.PaletteFile(fp)[source]
getpalette()[source]
rawmode = 'RGB'

PcfFontFile Module

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

Bases: PIL.FontFile.FontFile

name = 'name'
PIL.PcfFontFile.sz(s, o)[source]

TarIO Module

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

Bases: PIL.ContainerIO.ContainerIO

TiffTags Module

WalImageFile Module

PIL.WalImageFile.open(filename)[source]

_binary Module

PIL._binary.i16be(c, o=0)[source]
PIL._binary.i16le(c, o=0)[source]
PIL._binary.i32be(c, o=0)[source]
PIL._binary.i32le(c, o=0)[source]
PIL._binary.i8(c)[source]
PIL._binary.o16be(i)[source]
PIL._binary.o16le(i)[source]
PIL._binary.o32be(i)[source]
PIL._binary.o32le(i)[source]
PIL._binary.o8(i)[source]