Skip to content

Commit e8b3c17

Browse files
committed
Updated documentation
1 parent 74e36e0 commit e8b3c17

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

docs/deprecations.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ Image.fromarray mode parameter
4242

4343
.. deprecated:: 11.3.0
4444

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

4851
Saving I mode images as PNG
4952
^^^^^^^^^^^^^^^^^^^^^^^^^^^

docs/releasenotes/11.3.0.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ Image.fromarray mode parameter
2929
The ``mode`` parameter in :py:meth:`~PIL.Image.fromarray()` has been deprecated. The
3030
mode can be automatically determined from the object's shape and type instead.
3131

32+
.. note::
33+
34+
Since pixel values do not contain information about palettes or color spaces, part
35+
of this functionality was restored in Pillow 12.0.0. The parameter can be used to
36+
place grayscale L mode data within a P mode image, or read RGB data as YCbCr for
37+
example.
38+
3239
Saving I mode images as PNG
3340
^^^^^^^^^^^^^^^^^^^^^^^^^^^
3441

docs/releasenotes/12.0.0.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ TODO
134134
Other changes
135135
=============
136136

137-
TODO
138-
^^^^
137+
Image.fromarray mode parameter
138+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
139139

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

src/PIL/Image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3253,7 +3253,8 @@ def fromarray(obj: SupportsArrayInterface, mode: str | None = None) -> Image:
32533253
:param obj: Object with array interface
32543254
:param mode: Optional mode to use when reading ``obj``. Since pixel values do not
32553255
contain information about palettes or color spaces, this can be used to place
3256-
grayscale L mode data within a P mode image, or read RGB data as YCbCr.
3256+
grayscale L mode data within a P mode image, or read RGB data as YCbCr for
3257+
example.
32573258
32583259
See: :ref:`concept-modes` for general information about modes.
32593260
:returns: An image object.

0 commit comments

Comments
 (0)