Pillow 棄用和移除的功能

2021-07-20 18:04 更新

棄用和移除

此頁面列出了在過去的主要版本中已棄用或已刪除的 Pillow 功能,并提供了替代方案。

不推薦使用的功能

以下是被認(rèn)為不推薦使用的功能。在適當(dāng)?shù)那闆r下,會發(fā)出一個?DeprecationWarning?。

FreeType 2.7

自 8.1.0 版起已棄用。

對 FreeType 2.7 的支持已被棄用,并將在 Pillow 9.0.0 (2022-01-02) 中刪除,此時 FreeType 2.8 將是支持的最低要求。

我們建議至少升級到 FreeType 2.10.4,它修復(fù)了 FreeType 2.6 中引入的嚴(yán)重漏洞 ( CVE-2020-15999 )。

Image.show命令參數(shù)

7.2.0 版后已移除.

該?command?參數(shù)將在 Pillow 9.0.0 (2022-01-02) 中移除。使用?ImageShow.Viewer?的一個子類代替。

Image._showxv

7.2.0 版后已移除.

Image._showxv將在 Pillow 9.0.0 (2022-01-02) 中移除。使用Image.Image.show()來代替。如果需要自定義行為,請使用 ImageShow.register()添加自定義ImageShow.Viewer類。

ImageFile.raise_ioerror

7.2.0 版后已移除.

IOError被合并到Python3.3的OSError中。因此,ImageFile.raise_ioerror將在 Pillow 9.0.0 (2022-01-02) 中刪除。使用ImageFile.raise_oserror來代替。

PILLOW_VERSION 常量

5.2.0 版后已移除.

?PILLOW_VERSION?將在 Pillow 9.0.0 (2022-01-02) 中移除。使用?__version__?來代替。

它最初在 Pillow 7.0.0 中被刪除,但在 7.1.0 中被恢復(fù),以便為項(xiàng)目提供更多的升級時間。

Tk/Tcl 8.4

自 8.2.0 版起已棄用。

不推薦使用對 Tk/Tcl 8.4 的支持,并將在 Pillow 10.0.0 (2023-01-02) 中刪除,此時 Tk/Tcl 8.5 將是支持的最低版本。

類別

自 8.2.0 版起已棄用。

im.category已棄用,并將在 Pillow 10.0.0 (2023-01-02) 以及相關(guān)的Image.NORMAL,Image.SEQUENCE和 Image.CONTAINER屬性中刪除。

要確定圖像是否具有多個幀, 可以改用getattr(im, "is_animated", False)

JpegImagePlugin.convert_dict_qtables

自 8.3.0 版起已棄用。

JPEGquantization現(xiàn)在會自動轉(zhuǎn)換,但仍作為字典返回。該convert_dict_qtables方法不再對提供給它的數(shù)據(jù)執(zhí)行任何操作,已被棄用,并將在 Pillow 10.0.0 (2023-01-02) 中刪除。

刪除的功能

只有在適當(dāng)?shù)臈売闷谶^后,才會在主要版本中刪除棄用的功能。

im.offset

自 1.1.2 版起已棄用。

在 8.0.0 版中刪除。

im.offset()已刪除,請將ImageChops.offset()改為調(diào)用。

它被記錄為在 PIL 1.1.2 中已棄用,DeprecationWarning自 1.1.5、Exception自 Pillow 3.0.0 和NotImplementedError自 3.3.0 起提出。

Image.fromstring、im.fromstring 和 im.tostring

自 2.0.0 版起已棄用。

在 8.0.0 版中刪除。

  • ?Image.fromstring()?已刪除,請將?Image.frombytes()?改為調(diào)用。
  • ?im.fromstring()?已刪除,請?frombytes()?改為調(diào)用。
  • ?im.tostring()?已刪除,請?tobytes()?改為調(diào)用。

他們發(fā)布了?DeprecationWarning?自 2.0.0、?Exception?自 3.0.0 和?NotImplementedError?自 3.3.0 以來。

imagecms.cmsprofile屬性

自 3.2.0 版起已棄用。

在 8.0.0 版中刪除。

中的一些屬性?PIL.ImageCms.CmsProfile?已被刪除。從 6.0.0 開始,他們發(fā)布了一個?DeprecationWarning?:

已移除

改用

color_space

Padded xcolor_space

pcs

Padded connection_space

product_copyright

Unicode copyright

product_desc

Unicode profile_description

product_description

Unicode profile_description

product_manufacturer

Unicode manufacturer

product_model

Unicode model

Python 2.7

自 6.0.0 版起已棄用。

在 7.0.0 版中刪除。

Python 2.7 已于 2020 年 1 月 1 日走到生命盡頭。Pillow 6.x 是最后一個支持 Python 2 的系列。

Image.__del__

自 6.1.0 版起已棄用。

在 7.0.0 版中刪除。

隱式關(guān)閉圖像的底層文件?Image.__del__?已被刪除。使用上下文管理器或調(diào)用?Image.close()?以確定性方式關(guān)閉文件。

以前的方法:

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

改為使用:

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

PIL.*ImagePlugin.__version__ 屬性

自 6.0.0 版起已棄用。

在 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

自 6.0.0 版起已棄用。

在 7.0.0 版中刪除。

Qt 4 已于 2015 年 12 月 19 日停產(chǎn)。它的 Python 綁定也是 EOL:自 2018-08-31 以來的 PyQt4 和自 2015-10-14 以來的 PySide。

對 PyQt4 和 PySide 的支持已從?ImageQt?. 請升級到 PyQt5 或 PySide2。

設(shè)置TIFF圖像的大小

自 5.3.0 版起已棄用。

在 7.0.0 版中刪除。

直接設(shè)置 TIFF 圖像的大?。ɡ?im.size = (256, 256)?)會引發(fā)錯誤。使用?Image.resize?來代替。

版本常量

自 5.2.0 版起已棄用。

在 6.0.0 版中刪除。

?VERSION?(舊的 PIL 版本,總是 1.1.7)已被刪除。使用 ?__version__?來代替。

未記錄的ImageOps函數(shù)

自 4.3.0 版起已棄用。

在 6.0.0 版中刪除。

中的幾個未記錄的功能?ImageOps?已被刪除。使用等效項(xiàng)?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

自 4.0.0 版起已棄用。

在 6.0.0 版中刪除。

PIL.OleFileIO 作為供應(yīng)商文件和 Pillow 4.0.0 (2017-01) 被刪除,以支持上游 olefile Python 包,并替換為?ImportError?5.0.0 (2018-01)。已棄用的文件現(xiàn)已從 Pillow 中刪除。如果需要,從 PyPI 安裝(例如python3 -m pip install olefile?)。?


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號