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
ContainerIO Module¶
GdImageFile Module¶
GimpGradientFile Module¶
GimpPaletteFile Module¶
ImageShow Module¶
-
class
PIL.ImageShow.DisplayViewer[source]¶ Bases:
PIL.ImageShow.UnixViewer
-
class
PIL.ImageShow.UnixViewer[source]¶ Bases:
PIL.ImageShow.Viewer
-
class
PIL.ImageShow.XVViewer[source]¶ Bases:
PIL.ImageShow.UnixViewer
ImageTransform Module¶
-
class
PIL.ImageTransform.AffineTransform(data)[source]¶ Bases:
PIL.ImageTransform.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.
@def AffineTransform(matrix) @param matrix A 6-tuple (a, b, c, d, e, f) containing the first two rows
from an affine transform matrix.@see Image#Image.transform
-
method= 0¶
-
-
class
PIL.ImageTransform.ExtentTransform(data)[source]¶ Bases:
PIL.ImageTransform.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.
@def ExtentTransform(bbox) @param bbox A 4-tuple (x0, y0, x1, y1) which specifies two points in the
input image’s coordinate system.@see Image#Image.transform
-
method= 1¶
-
-
class
PIL.ImageTransform.MeshTransform(data)[source]¶ Bases:
PIL.ImageTransform.TransformDefine a mesh image transform. A mesh transform consists of one or more individual quad transforms.
@def MeshTransform(data) @param data A list of (bbox, quad) tuples. @see Image#Image.transform
-
method= 4¶
-
-
class
PIL.ImageTransform.QuadTransform(data)[source]¶ Bases:
PIL.ImageTransform.TransformDefine a quad image transform.
Maps a quadrilateral (a region defined by four corners) from the image to a rectangle of the given size.
@def QuadTransform(xy) @param xy An 8-tuple (x0, y0, x1, y1, x2, y2, y3, y3) which contain the
upper left, lower left, lower right, and upper right corner of the source quadrilateral.@see Image#Image.transform
-
method= 3¶
-
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.: https://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.: https://en.wikipedia.org/wiki/Quantization_matrix#Quantization_matrices, https://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:
- The base container of the preset is a list with sublists instead of dict. dict[0] -> list[0], dict[1] -> list[1], ...
- Each table in a preset is a list instead of an array.
- 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://web.archive.org/web/20120328125543/http://www.jpegcameras.com/libjpeg/libjpeg-3.html
PaletteFile Module¶
PcfFontFile Module¶
-
class
PIL.PcfFontFile.PcfFontFile(fp)[source]¶ Bases:
PIL.FontFile.FontFile-
name= 'name'¶
-
PngImagePlugin.iTXt Class¶
PngImagePlugin.PngInfo Class¶
-
class
PIL.PngImagePlugin.PngInfo[source]¶ Bases:
objectPNG chunk container (for use with save(pnginfo=))
-
add(cid, data)[source]¶ Appends an arbitrary chunk. Use with caution.
Parameters: - cid – a byte string, 4 bytes long.
- data – a byte string of the encoded data
-
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=0)[source]¶ Appends a text chunk.
Parameters: - key – latin-1 encodable text key name
- value – value for this key, text or an
PIL.PngImagePlugin.iTXtinstance - zip – compression flag
-
TarIO Module¶
-
class
PIL.TarIO.TarIO(tarfile, file)[source]¶ Bases:
PIL.ContainerIO.ContainerIO
_binary Module¶
-
PIL._binary.i16le(c, o=0)[source]¶ Converts a 2-bytes (16 bits) string to an integer.
c: string containing bytes to convert o: offset of bytes to convert in string