PIL Package

PIL Package

ArgImagePlugin Module

BdfFontFile Module

BmpImagePlugin Module

BufrStubImagePlugin Module

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]

CurImagePlugin Module

DcxImagePlugin Module

EpsImagePlugin Module

ExifTags Module

FitsStubImagePlugin Module

FliImagePlugin Module

FontFile Module

FpxImagePlugin Module

GbrImagePlugin Module

GdImageFile Module

GifImagePlugin Module

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'

GribStubImagePlugin Module

Hdf5StubImagePlugin Module

IcnsImagePlugin Module

IcoImagePlugin Module

ImImagePlugin Module

Image Module

ImageChops Module

ImageCms Module

ImageColor Module

ImageDraw Module

ImageDraw2 Module

ImageEnhance Module

ImageFile Module

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

ImageFilter Module

class PIL.ImageFilter.BLUR[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((5, 5), 16, 0, (1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1))
name = 'Blur'
class PIL.ImageFilter.BuiltinFilter[source]

Bases: PIL.ImageFilter.Kernel

class PIL.ImageFilter.CONTOUR[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((3, 3), 1, 255, (-1, -1, -1, -1, 8, -1, -1, -1, -1))
name = 'Contour'
class PIL.ImageFilter.DETAIL[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((3, 3), 6, 0, (0, -1, 0, -1, 10, -1, 0, -1, 0))
name = 'Detail'
class PIL.ImageFilter.EDGE_ENHANCE[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((3, 3), 2, 0, (-1, -1, -1, -1, 10, -1, -1, -1, -1))
name = 'Edge-enhance'
class PIL.ImageFilter.EDGE_ENHANCE_MORE[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((3, 3), 1, 0, (-1, -1, -1, -1, 9, -1, -1, -1, -1))
name = 'Edge-enhance More'
class PIL.ImageFilter.EMBOSS[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((3, 3), 1, 128, (-1, 0, 0, 0, 1, 0, 0, 0, 0))
name = 'Emboss'
class PIL.ImageFilter.FIND_EDGES[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((3, 3), 1, 0, (-1, -1, -1, -1, 8, -1, -1, -1, -1))
name = 'Find Edges'
class PIL.ImageFilter.Filter[source]

Bases: object

class PIL.ImageFilter.GaussianBlur(radius=2)[source]

Bases: PIL.ImageFilter.Filter

filter(image)[source]
name = 'GaussianBlur'
class PIL.ImageFilter.Kernel(size, kernel, scale=None, offset=0)[source]

Bases: PIL.ImageFilter.Filter

filter(image)[source]
class PIL.ImageFilter.MaxFilter(size=3)[source]

Bases: PIL.ImageFilter.RankFilter

name = 'Max'
class PIL.ImageFilter.MedianFilter(size=3)[source]

Bases: PIL.ImageFilter.RankFilter

name = 'Median'
class PIL.ImageFilter.MinFilter(size=3)[source]

Bases: PIL.ImageFilter.RankFilter

name = 'Min'
class PIL.ImageFilter.ModeFilter(size=3)[source]

Bases: PIL.ImageFilter.Filter

filter(image)[source]
name = 'Mode'
class PIL.ImageFilter.RankFilter(size, rank)[source]

Bases: PIL.ImageFilter.Filter

filter(image)[source]
name = 'Rank'
class PIL.ImageFilter.SHARPEN[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((3, 3), 16, 0, (-2, -2, -2, -2, 32, -2, -2, -2, -2))
name = 'Sharpen'
class PIL.ImageFilter.SMOOTH[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((3, 3), 13, 0, (1, 1, 1, 1, 5, 1, 1, 1, 1))
name = 'Smooth'
class PIL.ImageFilter.SMOOTH_MORE[source]

Bases: PIL.ImageFilter.BuiltinFilter

filterargs = ((5, 5), 100, 0, (1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 5, 44, 5, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1, 1))
name = 'Smooth More'
class PIL.ImageFilter.UnsharpMask(radius=2, percent=150, threshold=3)[source]

Bases: PIL.ImageFilter.Filter

filter(image)[source]
name = 'UnsharpMask'

ImageFont Module

ImageMath Module

ImageMode Module

class PIL.ImageMode.ModeDescriptor(mode, bands, basemode, basetype)[source]
PIL.ImageMode.getmode(mode)[source]

ImageOps Module

ImagePalette Module

ImagePath Module

ImageQt Module

ImageSequence Module

class PIL.ImageSequence.Iterator(im)[source]

ImageShow Module

ImageStat Module

ImageTk Module

ImageTransform Module

ImageWin Module

ImtImagePlugin Module

IptcImagePlugin Module

JpegImagePlugin Module

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

McIdasImagePlugin Module

MicImagePlugin Module

MpegImagePlugin Module

MspImagePlugin Module

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

PSDraw Module

PaletteFile Module

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

PalmImagePlugin Module

PcdImagePlugin Module

PcfFontFile Module

PcxImagePlugin Module

PdfImagePlugin Module

PixarImagePlugin Module

PngImagePlugin Module

PpmImagePlugin Module

PsdImagePlugin Module

SgiImagePlugin Module

SpiderImagePlugin Module

SunImagePlugin Module

TarIO Module

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

Bases: PIL.ContainerIO.ContainerIO

TgaImagePlugin Module

TiffImagePlugin Module

TiffTags Module

WalImageFile Module

WebPImagePlugin Module

WmfImagePlugin Module

XVThumbImagePlugin Module

XbmImagePlugin Module

XpmImagePlugin Module

_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]

Table Of Contents

Previous topic

Welcome to Pillow (PIL fork)’s documentation!

This Page