From eedff2d59bfe9ae6a66091521fe908e4c3ebd0f7 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Wed, 19 Nov 2014 12:49:06 -0800 Subject: [PATCH 1/2] Mode reference anchor --- docs/handbook/concepts.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/handbook/concepts.rst b/docs/handbook/concepts.rst index b5e5e44c1..61406d179 100644 --- a/docs/handbook/concepts.rst +++ b/docs/handbook/concepts.rst @@ -14,8 +14,10 @@ same dimensions and depth. To get the number and names of bands in an image, use the :py:meth:`~PIL.Image.Image.getbands` method. -Mode ----- +.. _concept-modes: + +Modes +----- The :term:`mode` of an image defines the type and depth of a pixel in the image. The current release supports the following standard modes: From d1f4633c7b729e70703945b5d9057c231d37405c Mon Sep 17 00:00:00 2001 From: wiredfool Date: Wed, 19 Nov 2014 12:49:27 -0800 Subject: [PATCH 2/2] Many links to mode concept anchor [ci skip] --- PIL/Image.py | 15 +++++++++------ docs/reference/Image.rst | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index d556df34c..c4f4005e9 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -804,7 +804,7 @@ class Image: use other thresholds, use the :py:meth:`~PIL.Image.Image.point` method. - :param mode: The requested mode. + :param mode: The requested mode. See: :ref:`concept-modes`. :param matrix: An optional conversion matrix. If given, this should be 4- or 16-tuple containing floating point values. :param dither: Dithering method, used when converting from @@ -2007,7 +2007,8 @@ def new(mode, size, color=0): """ Creates a new image with the given mode and size. - :param mode: The mode to use for the new image. + :param mode: The mode to use for the new image. See: + :ref:`concept-modes`. :param size: A 2-tuple, containing (width, height) in pixels. :param color: What color to use for the image. Default is black. If given, this should be a single integer or floating point value @@ -2047,7 +2048,7 @@ def frombytes(mode, size, data, decoder_name="raw", *args): :py:class:`~io.BytesIO` object, and use :py:func:`~PIL.Image.open` to load it. - :param mode: The image mode. + :param mode: The image mode. See: :ref:`concept-modes`. :param size: The image size. :param data: A byte buffer containing raw data for the given mode. :param decoder_name: What decoder to use. @@ -2099,7 +2100,7 @@ def frombuffer(mode, size, data, decoder_name="raw", *args): issues a warning if you do this; to disable the warning, you should provide the full set of parameters. See below for details. - :param mode: The image mode. + :param mode: The image mode. See: :ref:`concept-modes`. :param size: The image size. :param data: A bytes or other buffer object containing raw data for the given mode. @@ -2150,7 +2151,8 @@ def fromarray(obj, mode=None): :param obj: Object with array interface :param mode: Mode to use (will be determined from type if None) - :returns: An image memory. + See: :ref:`concept-modes`. + :returns: An image object. .. versionadded:: 1.1.6 """ @@ -2367,7 +2369,8 @@ def merge(mode, bands): """ Merge a set of single band images into a new multiband image. - :param mode: The mode to use for the output image. + :param mode: The mode to use for the output image. See: + :ref:`concept-modes`. :param bands: A sequence containing one single-band image for each band in the output image. All bands must have the same size. diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index 08af684d5..11d1131cb 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -164,7 +164,7 @@ Instances of the :py:class:`Image` class have the following attributes: Image mode. This is a string specifying the pixel format used by the image. Typical values are “1”, “L”, “RGB”, or “CMYK.” See - :doc:`../handbook/concepts` for a full list. + :ref:`concept-modes` for a full list. :type: :py:class:`string`