Updated documentation

This commit is contained in:
Andrew Murray 2025-07-29 07:28:03 +10:00
parent 74e36e0ee5
commit e8b3c17ebc
4 changed files with 21 additions and 6 deletions

View File

@ -42,8 +42,11 @@ Image.fromarray mode parameter
.. deprecated:: 11.3.0
The ``mode`` parameter in :py:meth:`~PIL.Image.fromarray()` has been deprecated. The
mode can be automatically determined from the object's shape and type instead.
Using the ``mode`` parameter in :py:meth:`~PIL.Image.fromarray()` to change data types
has been deprecated. Since pixel values do not contain information about palettes or
color spaces, the parameter can still be used to place grayscale L mode data within a
P mode image, or read RGB data as YCbCr for example. If omitted, the mode will be
automatically determined from the object's shape and type.
Saving I mode images as PNG
^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -29,6 +29,13 @@ Image.fromarray mode parameter
The ``mode`` parameter in :py:meth:`~PIL.Image.fromarray()` has been deprecated. The
mode can be automatically determined from the object's shape and type instead.
.. note::
Since pixel values do not contain information about palettes or color spaces, part
of this functionality was restored in Pillow 12.0.0. The parameter can be used to
place grayscale L mode data within a P mode image, or read RGB data as YCbCr for
example.
Saving I mode images as PNG
^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -134,7 +134,11 @@ TODO
Other changes
=============
TODO
^^^^
Image.fromarray mode parameter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TODO
In Pillow 11.3.0, the ``mode`` parameter in :py:meth:`~PIL.Image.fromarray()` was
deprecated. Part of this functionality has been restored in Pillow 12.0.0. Since pixel
values do not contain information about palettes or color spaces, the parameter can be
used to place grayscale L mode data within a P mode image, or read RGB data as YCbCr
for example.

View File

@ -3253,7 +3253,8 @@ def fromarray(obj: SupportsArrayInterface, mode: str | None = None) -> Image:
:param obj: Object with array interface
:param mode: Optional mode to use when reading ``obj``. Since pixel values do not
contain information about palettes or color spaces, this can be used to place
grayscale L mode data within a P mode image, or read RGB data as YCbCr.
grayscale L mode data within a P mode image, or read RGB data as YCbCr for
example.
See: :ref:`concept-modes` for general information about modes.
:returns: An image object.