Pillow/docs/releasenotes/9.2.0.rst

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

149 lines
5.6 KiB
ReStructuredText
Raw Normal View History

2022-04-16 18:36:21 +03:00
9.2.0
-----
2024-03-17 13:59:46 +03:00
Security
========
An additional decompression bomb check has been added for the GIF format.
2022-04-16 18:36:21 +03:00
Deprecations
============
PyQt5 and PySide2
^^^^^^^^^^^^^^^^^
.. deprecated:: 9.2.0
`Qt 5 reached end-of-life <https://www.qt.io/blog/qt-5.15-released>`_ on 2020-12-08 for
open-source users (and will reach EOL on 2023-12-08 for commercial licence holders).
Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed
in Pillow 10 (2023-07-01). Upgrade to
`PyQt6 <https://www.riverbankcomputing.com/static/Docs/PyQt6/>`_ or
2023-05-11 01:13:33 +03:00
`PySide6 <https://doc.qt.io/qtforpython-6/>`_ instead.
2022-04-16 18:36:21 +03:00
FreeTypeFont.getmask2 fill parameter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. deprecated:: 9.2.0
2022-04-16 18:36:21 +03:00
The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2`
has been deprecated and will be removed in Pillow 10 (2023-07-01).
2022-06-03 12:01:36 +03:00
PhotoImage.paste box parameter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. deprecated:: 9.2.0
The ``box`` parameter is unused. It will be removed in Pillow 10.0.0 (2023-07-01).
2022-05-17 10:31:18 +03:00
Image.coerce_e
2022-06-03 12:01:36 +03:00
^^^^^^^^^^^^^^
2022-05-17 10:31:18 +03:00
.. deprecated:: 9.2.0
This undocumented method has been deprecated and will be removed in Pillow 10
(2023-07-01).
2022-06-30 14:58:47 +03:00
Font size and offset methods
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. deprecated:: 9.2.0
Several functions for computing the size and offset of rendered text
have been deprecated and will be removed in Pillow 10 (2023-07-01):
=============================================================== =============================================================================================================
Deprecated Use instead
=============================================================== =============================================================================================================
``FreeTypeFont.getsize()`` and ``FreeTypeFont.getoffset()`` :py:meth:`.FreeTypeFont.getbbox` and :py:meth:`.FreeTypeFont.getlength`
``FreeTypeFont.getsize_multiline()`` :py:meth:`.ImageDraw.multiline_textbbox`
``ImageFont.getsize()`` :py:meth:`.ImageFont.getbbox` and :py:meth:`.ImageFont.getlength`
``TransposedFont.getsize()`` :py:meth:`.TransposedFont.getbbox` and :py:meth:`.TransposedFont.getlength`
``ImageDraw.textsize()`` and ``ImageDraw.multiline_textsize()`` :py:meth:`.ImageDraw.textbbox`, :py:meth:`.ImageDraw.textlength` and :py:meth:`.ImageDraw.multiline_textbbox`
``ImageDraw2.Draw.textsize()`` :py:meth:`.ImageDraw2.Draw.textbbox` and :py:meth:`.ImageDraw2.Draw.textlength`
=============================================================== =============================================================================================================
2022-06-30 14:58:47 +03:00
Previous code::
2022-09-03 15:23:05 +03:00
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)
2024-02-17 03:19:32 +03:00
width, height = draw.textsize("Hello world", font)
2022-09-03 15:23:05 +03:00
width, height = font.getsize_multiline("Hello\nworld")
2024-02-17 03:19:32 +03:00
width, height = draw.multiline_textsize("Hello\nworld", font)
2022-09-03 15:23:05 +03:00
Use instead::
2022-09-03 15:23:05 +03:00
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)
2024-02-17 03:19:32 +03:00
width = draw.textlength("Hello world", font)
2022-09-03 15:23:05 +03:00
2024-02-17 03:19:32 +03:00
left, top, right, bottom = draw.multiline_textbbox((0, 0), "Hello\nworld", font)
2022-09-03 15:23:05 +03:00
width, height = right - left, bottom - top
Previously, the ``size`` methods returned a ``height`` that included the vertical
2024-02-19 09:08:21 +03:00
offset of the text, while the new ``bbox`` methods distinguish this as a ``top``
offset.
.. image:: ../example/size_vs_bbox.png
2024-02-20 13:37:06 +03:00
:alt: In bbox methods, top measures the vertical distance above the text, while bottom measures that plus the vertical distance of the text itself. In size methods, height also measures the vertical distance above the text plus the vertical distance of the text itself.
2024-02-19 09:08:21 +03:00
:align: center
If you are using these methods for aligning text, consider using :ref:`text-anchors` instead
which avoid issues that can occur with non-English text or unusual fonts.
For example, instead of the following code::
from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
im = Image.new("RGB", (100, 100))
draw = ImageDraw.Draw(im)
width, height = draw.textsize("Hello world", font)
x, y = (100 - width) / 2, (100 - height) / 2
draw.text((x, y), "Hello world", font=font)
Use instead::
from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
im = Image.new("RGB", (100, 100))
draw = ImageDraw.Draw(im)
draw.text((100 / 2, 100 / 2), "Hello world", font=font, anchor="mm")
2022-04-16 18:36:21 +03:00
API Additions
=============
2022-06-11 15:31:07 +03:00
Image.apply_transparency
^^^^^^^^^^^^^^^^^^^^^^^^
2022-04-16 18:36:21 +03:00
2022-06-11 15:31:07 +03:00
Added :py:meth:`~PIL.Image.Image.apply_transparency`, a method to take a P mode image
with "transparency" in ``im.info``, and apply the transparency to the palette instead.
The image's palette mode will become "RGBA", and "transparency" will be removed from
``im.info``.
2022-04-16 18:36:21 +03:00
Other Changes
=============
2022-06-13 03:16:30 +03:00
Using gnome-screenshot on Linux
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2022-04-16 18:36:21 +03:00
2022-06-13 03:16:30 +03:00
In :py:meth:`~PIL.ImageGrab.grab` on Linux, if ``xdisplay`` is ``None`` then
``gnome-screenshot`` will be used to capture the display if it is installed. To capture
the default X11 display instead, pass ``xdisplay=""``.