弃用和移除

本页列出了不推荐使用的Pillow功能,或在过去的主要版本中删除的Pillow功能,并给出了替代使用的选项。

不推荐使用的功能

以下是被视为已弃用的功能。在适当的情况下,a DeprecationWarning 发行。

imagecms.cmsprofile属性

3.2.0 版后已移除.

中的一些属性 ImageCms.CmsProfile 已弃用。从6.0.0开始,他们发布了 DeprecationWarning

已弃用

代替使用

color_space

加垫的 xcolor_space

pcs

加垫的 connection_space

product_copyright

统一码 copyright

product_desc

统一码 profile_description

product_description

统一码 profile_description

product_manufacturer

统一码 manufacturer

product_model

统一码 model

删除的功能

不推荐使用的功能只有在经过适当的不推荐期之后才能在主要版本中删除。

Python 2.7

在版本7.0.0中删除。

Python2.7在2020年1月1日达到了生命的尽头。Pillow6.x是支持Python2的最后一个系列。

Image.__del__

在版本7.0.0中删除。

在中隐式关闭图像的基础文件 Image.__del__ 已删除。使用上下文管理器或调用 Image.close() 而是以确定的方式关闭文件。

以前的方法:

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

改为使用:

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

Pillow版本常数

在版本7.0.0中删除。

PILLOW_VERSION 已删除。使用 __version__ 相反。

pil.*imageplugin.u版本属性

在版本7.0.0中删除。

单个插件的版本常量已被删除。使用 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和Pyside

在版本7.0.0中删除。

qt 4在2015-12-19达到了寿命终止。它的python绑定也是eol:pyqt4(自2018-08-31)和pyside(自2015-10-14)。

PyQt4和PySide的支持已从 ImageQt . 请升级到PyQt5或PySide2。

设置TIFF图像的大小

在版本7.0.0中删除。

直接设置TIFF图像的大小(例如。 im.size = (256, 256) )抛出错误。使用 Image.resize 相反。

版本常量

已在版本6.0.0中删除。

VERSION (旧PIL版本,始终为1.1.7)已删除。使用 __version__ 相反。

未记录的ImageOps函数

已在版本6.0.0中删除。

ImageOps 已被删除。使用等价物 ImageFilter 而是:

远离的

代替使用

ImageOps.box_blur

ImageFilter.BoxBlur

ImageOps.gaussian_blur

ImageFilter.GaussianBlur

ImageOps.gblur

ImageFilter.GaussianBlur

ImageOps.usm

ImageFilter.UnsharpMask

ImageOps.unsharp_mask

ImageFilter.UnsharpMask

PIL.OleFileIO

已在版本6.0.0中删除。

pil.olefileio作为自动文件和 Pillow 4.0.0(2017-01)删除,以支持上游olefile python包,并替换为 ImportError 5.0.0(2018-01年)。不推荐使用的文件现在已从 Pillow 中删除。如果需要,从PYPI安装(例如 pip install olefile