Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Tests/test_image_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ def test_numpy(self) -> None:
assert numpy is not None
assert px[numpy.int32(1), numpy.int32(2)] == (18, 20, 59)

def test_deprecation(self) -> None:
im = Image.new("PA", (1, 1))
with pytest.warns(DeprecationWarning, match="'value' lists"):
im.putpixel((0, 0), [0, 0, 0]) # type: ignore[arg-type]


class TestImageGetPixel:
@staticmethod
Expand Down
8 changes: 8 additions & 0 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ The IM image format has been deprecated and removal is planned in Pillow 15.0.0
(2028-10-15). If you are using this format and would like to continue doing so,
open an issue about what other software uses it.

Image.putpixel 'value' lists
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. deprecated:: 13.0.0

Passing lists to the ``value`` parameter of :py:meth:`~PIL.Image.Image.putpixel` have
been deprecated. Use tuples instead.

ImageQt align8to32()
^^^^^^^^^^^^^^^^^^^^

Expand Down
6 changes: 6 additions & 0 deletions docs/releasenotes/13.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ The IM image format has been deprecated and removal is planned in Pillow 15.0.0
(2028-10-15). If you are using this format and would like to continue doing so,
open an issue about what other software uses it.

Image.putpixel 'value' lists
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Passing lists to the ``value`` parameter of :py:meth:`~PIL.Image.Image.putpixel` have
been deprecated. Use tuples instead.

JpegImageFile.load_djpeg
^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
5 changes: 4 additions & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2183,7 +2183,7 @@ def putpalette(
def putpixel(
self,
xy: tuple[int, int] | list[int],
value: float | tuple[int, ...] | list[int],
value: float | tuple[int, ...],
) -> None:
"""
Modifies the pixel at the given position. The color is given as
Expand Down Expand Up @@ -2213,6 +2213,9 @@ def putpixel(
and isinstance(value, (list, tuple))
and len(value) in [3, 4]
):
if isinstance(value, list): # type: ignore[unreachable]
deprecate("'value' lists", 14, "tuples", plural=True) # type: ignore[unreachable]

# RGB or RGBA value for a P or PA image
if self.mode == "PA":
alpha = value[3] if len(value) == 4 else 255
Expand Down