- PIL Package (autodoc of remaining modules)
- BdfFontFile Module
- ContainerIO Module
- FontFile Module
- GdImageFile Module
- GimpGradientFile Module
- GimpPaletteFile Module
- ImageDraw2 Module
- ImageShow Module
- ImageTransform Module
- JpegPresets Module
- PaletteFile Module
- PcfFontFile Module
- PngImagePlugin.iTXt Class
- PngImagePlugin.PngInfo Class
- TarIO Module
- WalImageFile Module
- _binary Module
PIL Package (autodoc of remaining modules)
Reference for modules whose documentation has not yet been ported or writtencan be found here.
BdfFontFile Module
- class
PIL.BdfFontFile.
BdfFontFile
(fp)[源代码] - 基类:
PIL.FontFile.FontFile
PIL.BdfFontFile.
bdfchar
(_f)[源代码]
ContainerIO Module
- class
PIL.ContainerIO.
ContainerIO
(file, offset, length)[源代码] 基类:
object
FontFile Module
- class
PIL.FontFile.
FontFile
[源代码] 基类:
object
PIL.FontFile.
puti16
(fp, values)[源代码]
GdImageFile Module
- class
PIL.GdImageFile.
GdImageFile
(fp=None, filename=None)[源代码] 基类:
PIL.ImageFile.ImageFile
PIL.GdImageFile.
open
(fp, mode='r')[源代码]
GimpGradientFile Module
- class
PIL.GimpGradientFile.
GimpGradientFile
(fp)[源代码] - 基类:
PIL.GimpGradientFile.GradientFile
PIL.GimpGradientFile.
curved
(middle, pos)[源代码]
PIL.GimpGradientFile.
linear
(middle, pos)[源代码]
PIL.GimpGradientFile.
sine
(middle, pos)[源代码]
PIL.GimpGradientFile.
spheredecreasing
(_middle, pos)[源代码]
PIL.GimpGradientFile.
sphereincreasing
(_middle, pos)[源代码]
GimpPaletteFile Module
ImageDraw2 Module
- class
PIL.ImageDraw2.
Brush
(color, opacity=255)[源代码] - 基类:
object
- class
PIL.ImageDraw2.
Draw
(image, size=None, color=None)[源代码] 基类:
object
arc
(xy, start, end, *options)[源代码]chord
(xy, start, end, *options)[源代码]ellipse
(xy, *options)[源代码]flush
()[源代码]line
(xy, *options)[源代码]pieslice
(xy, start, end, *options)[源代码]polygon
(xy, *options)[源代码]rectangle
(xy, *options)[源代码]render
(op, xy, pen, brush=None)[源代码]settransform
(offset)[源代码]symbol
(xy, symbol, *options)[源代码]text
(xy, text, font)[源代码]textsize
(text, font)[源代码]
- class
PIL.ImageDraw2.
Font
(color, file, size=12)[源代码] - 基类:
object
- class
PIL.ImageDraw2.
Pen
(color, width=1, opacity=255)[源代码] - 基类:
object
ImageShow Module
- class
PIL.ImageShow.
Viewer
[源代码] 基类:
object
PIL.ImageShow.
register
(viewer, order=1)[源代码]
PIL.ImageShow.
show
(image, title=None, **options)[源代码]
PIL.ImageShow.
which
(executable)[源代码]
ImageTransform Module
- class
PIL.ImageTransform.
AffineTransform
(data)[源代码]
- class
PIL.ImageTransform.
ExtentTransform
(data)[源代码]
- class
PIL.ImageTransform.
MeshTransform
(data)[源代码]
- class
PIL.ImageTransform.
QuadTransform
(data)[源代码]
- class
PIL.ImageTransform.
Transform
(data)[源代码] 基类:
PIL.Image.ImageTransformHandler
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 resolutionfor 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 and4:1:1 (or 4:2:0?).
You can get the subsampling of a JPEG with theJpegImagePlugin.get_subsampling(im) function.
Quantization tables
They are values use by the DCT (Discrete cosine transform) to removeunnecessary 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 dictdirectly as the qtables argument when saving a JPEG.
The tables format between im.quantization and quantization in presets differ in3 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 theJpegImagePlugin.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)[源代码]
PIL.PcfFontFile.
sz
(s, o)[源代码]
PngImagePlugin.iTXt Class
- class
PIL.PngImagePlugin.
iTXt
[源代码] - 基类:
str
Subclass of string to allow iTXt chunks to look like strings whilekeeping their extra information
参数:
- **value** – value for this key
- **lang** – language code
- **tkey** – UTF-8 version of the key name
PngImagePlugin.PngInfo Class
- class
PIL.PngImagePlugin.
PngInfo
[源代码] - 基类:
object
PNG chunk container (for use with save(pnginfo=))
add
(cid, data)[源代码]- Appends an arbitrary chunk. Use with caution.
参数:
- **cid** – a byte string, 4 bytes long.
- **data** – a byte string of the encoded data
additxt
(_key, value, lang='', tkey='', zip=False)[源代码]- Appends an iTXt chunk.
参数:
- **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
addtext
(_key, value, zip=0)[源代码]- Appends a text chunk.
参数:
- **key** – latin-1 encodable text key name
- **value** – value for this key, text or an[<code>PIL.PngImagePlugin.iTXt</code>](#PIL.PngImagePlugin.iTXt) instance
- **zip** – compression flag
TarIO Module
- class
PIL.TarIO.
TarIO
(tarfile, file)[源代码] - 基类:
PIL.ContainerIO.ContainerIO
WalImageFile Module
PIL.WalImageFile.
open
(filename)[源代码]
_binary Module
PIL.binary.
i16be
(_c, o=0)[源代码]
PIL.binary.
i16le
(_c, o=0)[源代码]- Converts a 2-bytes (16 bits) string to an integer.
c: string containing bytes to converto: offset of bytes to convert in string
PIL.binary.
i32be
(_c, o=0)[源代码]
PIL.binary.
i32le
(_c, o=0)[源代码]- Converts a 4-bytes (32 bits) string to an integer.
c: string containing bytes to converto: offset of bytes to convert in string
PIL.binary.
i8
(_c)[源代码]
PIL.binary.
o16be
(_i)[源代码]
PIL.binary.
o16le
(_i)[源代码]
PIL.binary.
o32be
(_i)[源代码]
PIL.binary.
o32le
(_i)[源代码]
PIL.binary.
o8
(_i)[源代码]