Added coordinate system links in documentation

This commit is contained in:
Andrew Murray 2018-06-24 14:34:01 +10:00
parent 968c2cf3c9
commit 7274636a7e
8 changed files with 26 additions and 17 deletions

View File

@ -58,6 +58,8 @@ You can read the image size through the :py:attr:`~PIL.Image.Image.size`
attribute. This is a 2-tuple, containing the horizontal and vertical size in attribute. This is a 2-tuple, containing the horizontal and vertical size in
pixels. pixels.
.. _coordinate-system:
Coordinate System Coordinate System
----------------- -----------------

View File

@ -1066,7 +1066,7 @@ class Image(object):
""" """
Returns a rectangular region from this image. The box is a Returns a rectangular region from this image. The box is a
4-tuple defining the left, upper, right, and lower pixel 4-tuple defining the left, upper, right, and lower pixel
coordinate. coordinate. See :ref:`coordinate-system`.
Note: Prior to Pillow 3.4.0, this was a lazy operation. Note: Prior to Pillow 3.4.0, this was a lazy operation.
@ -1173,8 +1173,9 @@ class Image(object):
image. image.
:returns: The bounding box is returned as a 4-tuple defining the :returns: The bounding box is returned as a 4-tuple defining the
left, upper, right, and lower pixel coordinate. If the image left, upper, right, and lower pixel coordinate. See
is completely empty, this method returns None. :ref:`coordinate-system`. If the image is completely empty, this
method returns None.
""" """
@ -1275,7 +1276,8 @@ class Image(object):
""" """
Returns the pixel value at a given position. Returns the pixel value at a given position.
:param xy: The coordinate, given as (x, y). :param xy: The coordinate, given as (x, y). See
:ref:`coordinate-system`.
:returns: The pixel value. If the image is a multi-layer image, :returns: The pixel value. If the image is a multi-layer image,
this method returns a tuple. this method returns a tuple.
""" """
@ -1335,8 +1337,8 @@ class Image(object):
Pastes another image into this image. The box argument is either Pastes another image into this image. The box argument is either
a 2-tuple giving the upper left corner, a 4-tuple defining the a 2-tuple giving the upper left corner, a 4-tuple defining the
left, upper, right, and lower pixel coordinate, or None (same as left, upper, right, and lower pixel coordinate, or None (same as
(0, 0)). If a 4-tuple is given, the size of the pasted image (0, 0)). See :ref:`coordinate-system`. If a 4-tuple is given, the size
must match the size of the region. of the pasted image must match the size of the region.
If the modes don't match, the pasted image is converted to the mode of If the modes don't match, the pasted image is converted to the mode of
this image (see the :py:meth:`~PIL.Image.Image.convert` method for this image (see the :py:meth:`~PIL.Image.Image.convert` method for
@ -1616,7 +1618,8 @@ class Image(object):
* :py:meth:`~PIL.Image.Image.putdata` * :py:meth:`~PIL.Image.Image.putdata`
* :py:mod:`~PIL.ImageDraw` * :py:mod:`~PIL.ImageDraw`
:param xy: The pixel coordinate, given as (x, y). :param xy: The pixel coordinate, given as (x, y). See
:ref:`coordinate-system`.
:param value: The pixel value. :param value: The pixel value.
""" """

View File

@ -327,7 +327,8 @@ def floodfill(image, xy, value, border=None, thresh=0):
(experimental) Fills a bounded region with a given color. (experimental) Fills a bounded region with a given color.
:param image: Target image. :param image: Target image.
:param xy: Seed position (a 2-item coordinate tuple). :param xy: Seed position (a 2-item coordinate tuple). See
:ref:`coordinate-system`.
:param value: Fill color. :param value: Fill color.
:param border: Optional border value. If given, the region consists of :param border: Optional border value. If given, the region consists of
pixels with a color different from the border color. If not given, pixels with a color different from the border color. If not given,

View File

@ -211,7 +211,7 @@ class MorphOp(object):
an image. an image.
Returns a list of tuples of (x,y) coordinates Returns a list of tuples of (x,y) coordinates
of all matching pixels.""" of all matching pixels. See :ref:`coordinate-system`."""
if self.lut is None: if self.lut is None:
raise Exception('No operator loaded') raise Exception('No operator loaded')
@ -223,7 +223,7 @@ class MorphOp(object):
"""Get a list of all turned on pixels in a binary image """Get a list of all turned on pixels in a binary image
Returns a list of tuples of (x,y) coordinates Returns a list of tuples of (x,y) coordinates
of all matching pixels.""" of all matching pixels. See :ref:`coordinate-system`."""
if image.mode != 'L': if image.mode != 'L':
raise Exception('Image must be binary, meaning it must use mode L') raise Exception('Image must be binary, meaning it must use mode L')

View File

@ -169,8 +169,8 @@ class PhotoImage(object):
mode does not match, the image is converted to the mode of mode does not match, the image is converted to the mode of
the bitmap image. the bitmap image.
:param box: A 4-tuple defining the left, upper, right, and lower pixel :param box: A 4-tuple defining the left, upper, right, and lower pixel
coordinate. If None is given instead of a tuple, all of coordinate. See :ref:`coordinate-system`. If None is given
the image is assumed. instead of a tuple, all of the image is assumed.
""" """
# convert to blittable # convert to blittable

View File

@ -65,7 +65,7 @@ class ExtentTransform(Transform):
See :py:meth:`~PIL.Image.Image.transform` See :py:meth:`~PIL.Image.Image.transform`
:param bbox: A 4-tuple (x0, y0, x1, y1) which specifies two points in the :param bbox: A 4-tuple (x0, y0, x1, y1) which specifies two points in the
input image's coordinate system. input image's coordinate system. See :ref:`coordinate-system`.
""" """
method = Image.EXTENT method = Image.EXTENT

View File

@ -154,8 +154,9 @@ class Dib(object):
If the mode does not match, the image is converted to the If the mode does not match, the image is converted to the
mode of the bitmap image. mode of the bitmap image.
:param box: A 4-tuple defining the left, upper, right, and :param box: A 4-tuple defining the left, upper, right, and
lower pixel coordinate. If None is given instead of a lower pixel coordinate. See :ref:`coordinate-system`. If
tuple, all of the image is assumed. None is given instead of a tuple, all of the image is
assumed.
""" """
im.load() im.load()
if self.mode != im.mode: if self.mode != im.mode:

View File

@ -68,7 +68,8 @@ class PyAccess(object):
numerical value for single band images, and a tuple for numerical value for single band images, and a tuple for
multi-band images multi-band images
:param xy: The pixel coordinate, given as (x, y). :param xy: The pixel coordinate, given as (x, y). See
:ref:`coordinate-system`.
:param color: The pixel value. :param color: The pixel value.
""" """
if self.readonly: if self.readonly:
@ -82,7 +83,8 @@ class PyAccess(object):
value for single band images or a tuple for multiple band value for single band images or a tuple for multiple band
images images
:param xy: The pixel coordinate, given as (x, y). :param xy: The pixel coordinate, given as (x, y). See
:ref:`coordinate-system`.
:returns: a pixel value for single band images, a tuple of :returns: a pixel value for single band images, a tuple of
pixel values for multiband images. pixel values for multiband images.
""" """