7.0.0

向后兼容的改变

Python 2.7

枕头已下降为Python 2.7,达到了结束生命的2020年1月1日的支持。

PILLOW_VERSION不变

PILLOW_VERSION 已被删除。 采用 __version__ 代替.

PIL.*ImagePlugin.__version__ 属性

各个插件的版本常数已被删除。使用 PIL.__version__ 代替。

删除

删除

删除

BmpImagePlugin.__version__

Jpeg2KImagePlugin.__version__

PngImagePlugin.__version__

CurImagePlugin.__version__

JpegImagePlugin.__version__

PpmImagePlugin.__version__

DcxImagePlugin.__version__

McIdasImagePlugin.__version__

PsdImagePlugin.__version__

EpsImagePlugin.__version__

MicImagePlugin.__version__

SgiImagePlugin.__version__

FliImagePlugin.__version__

MpegImagePlugin.__version__

SunImagePlugin.__version__

FpxImagePlugin.__version__

MpoImagePlugin.__version__

TgaImagePlugin.__version__

GdImageFile.__version__

MspImagePlugin.__version__

TiffImagePlugin.__version__

GifImagePlugin.__version__

PalmImagePlugin.__version__

WmfImagePlugin.__version__

IcoImagePlugin.__version__

PcdImagePlugin.__version__

XbmImagePlugin.__version__

ImImagePlugin.__version__

PcxImagePlugin.__version__

XpmImagePlugin.__version__

ImtImagePlugin.__version__

PdfImagePlugin.__version__

XVThumbImagePlugin.__version__

IptcImagePlugin.__version__

PixarImagePlugin.__version__

PyQt4 and PySide

Qt 4 reached end-of-life on 2015-12-19. Its Python bindings are also EOL: PyQt4 since 2018-08-31 and PySide since 2015-10-14.

对于PyQt4的和PySide支持已经从 ImageQt 删除。请升级到PyQt5或PySide2。

设置TIFF图像的大小

Setting the size of a TIFF image directly (eg. im.size = (256, 256)) throws an error. Use Image.resize instead.

默认重采样滤波器

The default resampling filter has been changed to the high-quality convolution Image.BICUBIC instead of Image.NEAREST, for the resize() method and the pad(), scale() and fit() functions. Image.NEAREST is still always used for images in “P” and “1” modes. See Filters to learn the difference. In short, Image.NEAREST is a very fast filter, but simple and low-quality.

Image.draft() 返回值

If the draft() method has no effect, it returns None. If it does have an effect, then it previously returned the image itself. However, unlike other chain methods, draft() does not return a modified version of the image, but modifies it in-place. So instead, if draft() has an effect, Pillow will now return a tuple of the image mode and a co-ordinate box. The box is the original coordinates in the bounds of resulting image. This may be useful in a subsequent resize() call.

API Additions

自定义不明的图像错误

Pillow will now throw a custom UnidentifiedImageError when an image cannot be identified. For backwards compatibility, this will inherit from IOError.

新的参数``reducing_gap``为Image.resize()和Image.thumbnail()方法

Speeds up resizing by resizing the image in two steps. The bigger reducing_gap, the closer the result to the fair resampling. The smaller reducing_gap, the faster resizing. With reducing_gap greater or equal to 3.0, the result is indistinguishable from fair resampling.

PY::为默认值甲基:〜PIL.Image.Image.resize`是``None`,这意味着优化默认关闭。

The default value for thumbnail() is 2.0, which is very close to fair resampling while still being faster in many cases. In addition, the same gap is applied when thumbnail() calls draft(), which may greatly improve the quality of JPEG thumbnails. As a result, thumbnail() in the new version provides equally high speed and high quality from any source (JPEG or arbitrary images).

新Image.reduce()方法

reduce() is a highly efficient operation to reduce an image by integer times. Normally, it shouldn’t be used directly. Used internally by resize() and thumbnail() methods to speed up resize when a new argument reducing_gap is set.

在给定的DPI加载WMF图像

在Windows中,枕头可以阅读WMF文件,使用默认的72的图像的DPI现在也可以在另一项决议中加载:

from PIL import Image
with Image.open("drawing.wmf") as im:
    im.load(dpi=144)

Other Changes

Image.__del__

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

以前的方法:

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

Use instead:

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

更好的缩略图几何

When calculating the new dimensions in thumbnail(), round to the nearest integer, instead of always rounding down. This better preserves the original aspect ratio.

当图像宽度或高度不能被8整除的图像中的最后行和列得到JPEG DCT缩放后的重量正确。