|
1 | 1 | 11.2.1
|
2 | 2 | ------
|
3 | 3 |
|
| 4 | +.. warning:: |
| 5 | + |
| 6 | + The release of Pillow *11.2.0* was halted prematurely, due to hitting PyPI's |
| 7 | + project size limit and concern over the size of Pillow wheels containing libavif. |
| 8 | + The PyPI limit has now been increased and Pillow *11.2.1* has been released |
| 9 | + instead, without libavif included in the wheels. |
| 10 | + To avoid confusion, the incomplete 11.2.0 release has been removed from PyPI. |
| 11 | + |
| 12 | +Security |
| 13 | +======== |
| 14 | + |
| 15 | +Undefined shift when loading compressed DDS images |
| 16 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 17 | + |
| 18 | +When loading some compressed DDS formats, an integer was bitshifted by 24 places to |
| 19 | +generate the 32 bits of the lookup table. This was undefined behaviour, and has been |
| 20 | +present since Pillow 3.4.0. |
| 21 | + |
| 22 | +Deprecations |
| 23 | +============ |
| 24 | + |
| 25 | +Image.Image.get_child_images() |
| 26 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 27 | + |
| 28 | +.. deprecated:: 11.2.1 |
| 29 | + |
| 30 | +``Image.Image.get_child_images()`` has been deprecated. and will be removed in Pillow |
| 31 | +13 (2026-10-15). It will be moved to ``ImageFile.ImageFile.get_child_images()``. The |
| 32 | +method uses an image's file pointer, and so child images could only be retrieved from |
| 33 | +an :py:class:`PIL.ImageFile.ImageFile` instance. |
| 34 | + |
| 35 | +API Changes |
| 36 | +=========== |
| 37 | + |
| 38 | +``append_images`` no longer requires ``save_all`` |
| 39 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 40 | + |
| 41 | +Previously, ``save_all`` was required to in order to use ``append_images``. Now, |
| 42 | +``save_all`` will default to ``True`` if ``append_images`` is not empty and the format |
| 43 | +supports saving multiple frames:: |
| 44 | + |
| 45 | + im.save("out.gif", append_images=ims) |
| 46 | + |
| 47 | +API Additions |
| 48 | +============= |
| 49 | + |
| 50 | +``"justify"`` multiline text alignment |
| 51 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 52 | + |
| 53 | +In addition to ``"left"``, ``"center"`` and ``"right"``, multiline text can also be |
| 54 | +aligned using ``"justify"`` in :py:mod:`~PIL.ImageDraw`:: |
| 55 | + |
| 56 | + from PIL import Image, ImageDraw |
| 57 | + im = Image.new("RGB", (50, 25)) |
| 58 | + draw = ImageDraw.Draw(im) |
| 59 | + draw.multiline_text((0, 0), "Multiline\ntext 1", align="justify") |
| 60 | + draw.multiline_textbbox((0, 0), "Multiline\ntext 2", align="justify") |
| 61 | + |
| 62 | +Specify window in ImageGrab on Windows |
| 63 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 64 | + |
| 65 | +When using :py:meth:`~PIL.ImageGrab.grab`, a specific window can be selected using the |
| 66 | +HWND:: |
| 67 | + |
| 68 | + from PIL import ImageGrab |
| 69 | + ImageGrab.grab(window=hwnd) |
| 70 | + |
| 71 | +Check for MozJPEG |
| 72 | +^^^^^^^^^^^^^^^^^ |
| 73 | + |
| 74 | +You can check if Pillow has been built against the MozJPEG version of the |
| 75 | +libjpeg library, and what version of MozJPEG is being used:: |
| 76 | + |
| 77 | + from PIL import features |
| 78 | + features.check_feature("mozjpeg") # True or False |
| 79 | + features.version_feature("mozjpeg") # "4.1.1" for example, or None |
| 80 | + |
| 81 | +Saving compressed DDS images |
| 82 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 83 | + |
| 84 | +Compressed DDS images can now be saved using a ``pixel_format`` argument. DXT1, DXT3, |
| 85 | +DXT5, BC2, BC3 and BC5 are supported:: |
| 86 | + |
| 87 | + im.save("out.dds", pixel_format="DXT1") |
| 88 | + |
| 89 | +Other Changes |
| 90 | +============= |
| 91 | + |
| 92 | +Arrow support |
| 93 | +^^^^^^^^^^^^^ |
| 94 | + |
| 95 | +`Arrow <https://arrow.apache.org/>`__ is an in-memory data exchange format that is the |
| 96 | +spiritual successor to the NumPy array interface. It provides for zero-copy access to |
| 97 | +columnar data, which in our case is ``Image`` data. |
| 98 | + |
| 99 | +To create an image with zero-copy shared memory from an object exporting the |
| 100 | +arrow_c_array interface protocol:: |
| 101 | + |
| 102 | + from PIL import Image |
| 103 | + import pyarrow as pa |
| 104 | + arr = pa.array([0]*(5*5*4), type=pa.uint8()) |
| 105 | + im = Image.fromarrow(arr, 'RGBA', (5, 5)) |
| 106 | + |
| 107 | +Pillow images can also be converted to Arrow objects:: |
| 108 | + |
| 109 | + from PIL import Image |
| 110 | + import pyarrow as pa |
| 111 | + im = Image.open('hopper.jpg') |
| 112 | + arr = pa.array(im) |
| 113 | + |
4 | 114 | Reading and writing AVIF images
|
5 | 115 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
6 | 116 |
|
7 |
| -The release of Pillow 11.2.0 was halted prematurely, due to concern over the size of |
8 |
| -Pillow wheels containing libavif. |
9 |
| - |
10 |
| -Instead, Pillow 11.2.1's wheels do not contain libavif. If you wish to read and write |
11 |
| -AVIF images, you will need to build Pillow from source with libavif 1.0.0 or later. |
| 117 | +Pillow can now read and write AVIF images when built from source with libavif 1.0.0 |
| 118 | +or later. |
0 commit comments