9.2.0#
废弃#
PyQt5和PySide2#
自 9.2.0 版本弃用.
Qt 5 reached end-of-life 对于开源用户,将于2020-12-08年月到期(对于商业许可证持有者,将于2023-12-08年年达到停产)。
已弃用对PyQt5和PySide2的支持 ImageQt
并将在枕头10(2023-07-01)中移除。升级到 PyQt6 或 PySide6 取而代之的是。
FreeTypeFont.getmask2填充参数#
自 9.2.0 版本弃用.
未登记的人 fill
的参数 FreeTypeFont.getmask2()
已弃用,将在枕头10中删除(2023-07-01)。
PhotoImage.Paste box参数#
自 9.2.0 版本弃用.
这个 box
参数未使用。它将在枕头10.0.0(2023-07-01)中删除。
Image.coerce_e#
自 9.2.0 版本弃用.
这种未记录的方法已被弃用,将在Pillow 10(2023-07-01)中删除。
字体大小和偏移方法#
自 9.2.0 版本弃用.
几个用于计算渲染文本的大小和偏移量的函数已弃用,将在Pillow 10(2023-07-01)中删除:
已弃用 |
代替使用 |
---|---|
|
|
|
|
|
|
|
|
|
|
|
以前的代码::
from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
width, height = font.getsize("Hello world")
left, top = font.getoffset("Hello world")
im = Image.new("RGB", (100, 100))
draw = ImageDraw.Draw(im)
width, height = draw.textsize("Hello world")
width, height = font.getsize_multiline("Hello\nworld")
width, height = draw.multiline_textsize("Hello\nworld")
改用::
from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
left, top, right, bottom = font.getbbox("Hello world")
width, height = right - left, bottom - top
im = Image.new("RGB", (100, 100))
draw = ImageDraw.Draw(im)
width = draw.textlength("Hello world")
left, top, right, bottom = draw.multiline_textbbox((0, 0), "Hello\nworld")
width, height = right - left, bottom - top
API添加#
Image.apply_transparency#
增列 apply_transparency()
,一种在P模式下拍摄透明图像的方法 im.info
,并改为将透明度应用于调色板。图像的调色板模式将变为“RGBA”,并且“透明”将从 im.info
。
安全性#
为GIF格式添加了额外的解压缩炸弹检查。
其他变化#
在Linux上使用GNOME-Screenshot#
在……里面 grab()
在Linux上,如果 xdisplay
是 None
然后 gnome-screenshot
将用于捕获显示屏(如果已安装)。要捕获默认的X11显示,请传递 xdisplay=""
。