6.1.0

Deprecations

Image.__del__

6.1.0 版后已移除.

Implicitly closing the image’s underlying file in Image.__del__ has been deprecated. Use a context manager or call Image.close() instead to close the file in a deterministic way.

Deprecated:

im = Image.open("hopper.png")
im.save("out.jpg")

Use instead:

with Image.open("hopper.png") as im:
    im.save("out.jpg")

API Additions

Image.entropy

Calculates and returns the entropy for the image. A bilevel image (mode “1”) is treated as a greyscale (“L”) image by this method. If a mask is provided, the method employs the histogram for those parts of the image where the mask image is non-zero. The mask image must have the same size as the image, and be either a bi-level image (mode “1”) or a greyscale image (“L”).

ImageGrab.grab

An optional include_layered_windows parameter has been added to ImageGrab.grab, defaulting to False. If true, layered windows will be included in the resulting image on Windows.

ImageSequence.all_frames

A new method to facilitate applying a given function to all frames in an image, or to all frames in a list of images. The frames are returned as a list of separate images. For example, ImageSequence.all_frames(im, lambda im_frame: im_frame.rotate(90)) could be used to return all frames from an image, each rotated 90 degrees.

变异字体

Variation fonts are now supported, allowing for different styles from the same font file. ImageFont.FreeTypeFont has four new methods, PIL.ImageFont.FreeTypeFont.get_variation_names() and PIL.ImageFont.FreeTypeFont.set_variation_by_name() for using named styles, and PIL.ImageFont.FreeTypeFont.get_variation_axes() and PIL.ImageFont.FreeTypeFont.set_variation_by_axes() for using font axes instead. An IOError will be raised if the font is not a variation font. FreeType 2.9.1 or greater is required.

Other Changes

ImageTk.getimage

现在支持此功能。它返回一个``ImageTk.PhotoImage``作为RGBA``Image.Image``实例的内容。

图像质量的JPEG压缩TIFF

The TIFF encoder accepts a quality parameter for jpeg compressed TIFF files. A value from 0 (worst) to 100 (best) controls the image quality, similar to the JPEG encoder. The default is 75. For example:

im.save("out.tif", compression="jpeg", quality=85)

提高TIFF标签的编码

的TIFF编码器支持多种类型的,特别是阵列。这是所必需的的GeoTIFF格式编码的地理空间信息。

  • 通过``从V2目录tagtype``到的libtiff编码器,而不是自动探测类型。

  • 使用显式类型如。 ``uint32_t``为``TIFF_LONG``来修复问题与64位多头平台。

  • 添加多个值(数组)的支持。需要键入V2目录和价值观必须作为一个元组进行传递。

  • 添加符号类型如支持。 TIFFTypes.TIFF_SIGNED_SHORT

建设时必须尊重PKG_CONFIG环境变量

这个变量是常用的其他构建系统,使用它可与交叉编译帮助。回落到``PKG-config``如前。

顶至底的复杂文本渲染

用`图中的“TTB”方向文本`ImageFont``已显著提高,并且需要Raqm 0.7或更大。