From b7a1ba8e9cfe180572e69f8561302f1bf02d6094 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 24 Oct 2026 01:01:45 +1100 Subject: [PATCH] Mention negative index access --- docs/handbook/concepts.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/handbook/concepts.rst b/docs/handbook/concepts.rst index 496748f44a7..b8bf116d7cd 100644 --- a/docs/handbook/concepts.rst +++ b/docs/handbook/concepts.rst @@ -95,6 +95,16 @@ Coordinates are usually passed to the library as 2-tuples (x, y). Rectangles are represented as 4-tuples, (x1, y1, x2, y2), with the upper left corner given first. +Since Pillow 5.4.0, individual image pixels can be accessed using negative indexes. +For example, to get or set the farthest pixel in the lower right of an image:: + + >>> from PIL import Image + >>> im = Image.new("RGB", (10, 10), (255, 0, 0)) + >>> px = im.load() + >>> px[-1, -1] + (255, 0, 0) + >>> px[-1, -1] = (0, 0, 0) + Palette -------