Merge pull request #6099 from radarhere/pixels

Document alternatives to accessing individual pixels
This commit is contained in:
Hugo van Kemenade 2022-03-06 09:17:45 +02:00 committed by GitHub
commit fe9b6998f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -6,7 +6,13 @@
The PixelAccess class provides read and write access to The PixelAccess class provides read and write access to
:py:class:`PIL.Image` data at a pixel level. :py:class:`PIL.Image` data at a pixel level.
.. note:: Accessing individual pixels is fairly slow. If you are looping over all of the pixels in an image, there is likely a faster way using other parts of the Pillow API. .. note:: Accessing individual pixels is fairly slow. If you are
looping over all of the pixels in an image, there is likely
a faster way using other parts of the Pillow API.
:mod:`~PIL.Image`, :mod:`~PIL.ImageChops` and :mod:`~PIL.ImageOps`
have methods for many standard operations. If you wish to perform
a custom mapping, check out :py:meth:`~PIL.Image.Image.point`.
Example Example
------- -------
@ -39,7 +45,7 @@ Access using negative indexes is also possible.
:py:class:`PixelAccess` Class :py:class:`PixelAccess` Class
----------------------------------- -----------------------------
.. class:: PixelAccess .. class:: PixelAccess

View File

@ -7,8 +7,12 @@
The :py:mod:`~PIL.PyAccess` module provides a CFFI/Python implementation of the :ref:`PixelAccess`. This implementation is far faster on PyPy than the PixelAccess version. The :py:mod:`~PIL.PyAccess` module provides a CFFI/Python implementation of the :ref:`PixelAccess`. This implementation is far faster on PyPy than the PixelAccess version.
.. note:: Accessing individual pixels is fairly slow. If you are .. note:: Accessing individual pixels is fairly slow. If you are
looping over all of the pixels in an image, there is likely looping over all of the pixels in an image, there is likely
a faster way using other parts of the Pillow API. a faster way using other parts of the Pillow API.
:mod:`~PIL.Image`, :mod:`~PIL.ImageChops` and :mod:`~PIL.ImageOps`
have methods for many standard operations. If you wish to perform
a custom mapping, check out :py:meth:`~PIL.Image.Image.point`.
Example Example
------- -------