Skip to content

Commit a36b766

Browse files
committed
Simplified enum references
1 parent 3f960d9 commit a36b766

File tree

2 files changed

+35
-45
lines changed

2 files changed

+35
-45
lines changed

docs/reference/Image.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ Functions
5353
To protect against potential DOS attacks caused by "`decompression bombs`_" (i.e. malicious files
5454
which decompress into a huge amount of data and are designed to crash or cause disruption by using up
5555
a lot of memory), Pillow will issue a ``DecompressionBombWarning`` if the number of pixels in an
56-
image is over a certain limit, :py:data:`PIL.Image.MAX_IMAGE_PIXELS`.
56+
image is over a certain limit, :py:data:`MAX_IMAGE_PIXELS`.
5757

58-
This threshold can be changed by setting :py:data:`PIL.Image.MAX_IMAGE_PIXELS`. It can be disabled
58+
This threshold can be changed by setting :py:data:`MAX_IMAGE_PIXELS`. It can be disabled
5959
by setting ``Image.MAX_IMAGE_PIXELS = None``.
6060

6161
If desired, the warning can be turned into an error with
6262
``warnings.simplefilter('error', Image.DecompressionBombWarning)`` or suppressed entirely with
6363
``warnings.simplefilter('ignore', Image.DecompressionBombWarning)``. See also
6464
`the logging documentation`_ to have warnings output to the logging facility instead of stderr.
6565

66-
If the number of pixels is greater than twice :py:data:`PIL.Image.MAX_IMAGE_PIXELS`, then a
66+
If the number of pixels is greater than twice :py:data:`MAX_IMAGE_PIXELS`, then a
6767
``DecompressionBombError`` will be raised instead.
6868

6969
.. _decompression bombs: https://en.wikipedia.org/wiki/Zip_bomb
@@ -255,7 +255,7 @@ This rotates the input image by ``theta`` degrees counter clockwise:
255255
.. automethod:: PIL.Image.Image.transform
256256
.. automethod:: PIL.Image.Image.transpose
257257

258-
This flips the input image by using the :data:`PIL.Image.Transpose.FLIP_LEFT_RIGHT`
258+
This flips the input image by using the :data:`Transpose.FLIP_LEFT_RIGHT`
259259
method.
260260

261261
.. code-block:: python

src/PIL/Image.py

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,18 +1989,14 @@ def resize(self, size, resample=None, box=None, reducing_gap=None):
19891989
:param size: The requested size in pixels, as a 2-tuple:
19901990
(width, height).
19911991
:param resample: An optional resampling filter. This can be
1992-
one of :py:data:`PIL.Image.Resampling.NEAREST`,
1993-
:py:data:`PIL.Image.Resampling.BOX`,
1994-
:py:data:`PIL.Image.Resampling.BILINEAR`,
1995-
:py:data:`PIL.Image.Resampling.HAMMING`,
1996-
:py:data:`PIL.Image.Resampling.BICUBIC` or
1997-
:py:data:`PIL.Image.Resampling.LANCZOS`.
1992+
one of :py:data:`Resampling.NEAREST`, :py:data:`Resampling.BOX`,
1993+
:py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`,
1994+
:py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`.
19981995
If the image has mode "1" or "P", it is always set to
1999-
:py:data:`PIL.Image.Resampling.NEAREST`.
2000-
If the image mode specifies a number of bits, such as "I;16", then the
2001-
default filter is :py:data:`PIL.Image.Resampling.NEAREST`.
2002-
Otherwise, the default filter is
2003-
:py:data:`PIL.Image.Resampling.BICUBIC`. See: :ref:`concept-filters`.
1996+
:py:data:`Resampling.NEAREST`. If the image mode specifies a number
1997+
of bits, such as "I;16", then the default filter is
1998+
:py:data:`Resampling.NEAREST`. Otherwise, the default filter is
1999+
:py:data:`Resampling.BICUBIC`. See: :ref:`concept-filters`.
20042000
:param box: An optional 4-tuple of floats providing
20052001
the source image region to be scaled.
20062002
The values must be within (0, 0, width, height) rectangle.
@@ -2140,12 +2136,12 @@ def rotate(
21402136
21412137
:param angle: In degrees counter clockwise.
21422138
:param resample: An optional resampling filter. This can be
2143-
one of :py:data:`PIL.Image.Resampling.NEAREST` (use nearest neighbour),
2144-
:py:data:`PIL.Image.BILINEAR` (linear interpolation in a 2x2
2145-
environment), or :py:data:`PIL.Image.Resampling.BICUBIC`
2146-
(cubic spline interpolation in a 4x4 environment).
2147-
If omitted, or if the image has mode "1" or "P", it is
2148-
set to :py:data:`PIL.Image.Resampling.NEAREST`. See :ref:`concept-filters`.
2139+
one of :py:data:`Resampling.NEAREST` (use nearest neighbour),
2140+
:py:data:`Resampling.BILINEAR` (linear interpolation in a 2x2
2141+
environment), or :py:data:`Resampling.BICUBIC` (cubic spline
2142+
interpolation in a 4x4 environment). If omitted, or if the image has
2143+
mode "1" or "P", it is set to :py:data:`Resampling.NEAREST`.
2144+
See :ref:`concept-filters`.
21492145
:param expand: Optional expansion flag. If true, expands the output
21502146
image to make it large enough to hold the entire rotated image.
21512147
If false or omitted, make the output image the same size as the
@@ -2452,14 +2448,11 @@ def thumbnail(self, size, resample=Resampling.BICUBIC, reducing_gap=2.0):
24522448
24532449
:param size: Requested size.
24542450
:param resample: Optional resampling filter. This can be one
2455-
of :py:data:`PIL.Image.Resampling.NEAREST`,
2456-
:py:data:`PIL.Image.Resampling.BOX`,
2457-
:py:data:`PIL.Image.Resampling.BILINEAR`,
2458-
:py:data:`PIL.Image.Resampling.HAMMING`,
2459-
:py:data:`PIL.Image.Resampling.BICUBIC` or
2460-
:py:data:`PIL.Image.Resampling.LANCZOS`.
2461-
If omitted, it defaults to :py:data:`PIL.Image.Resampling.BICUBIC`.
2462-
(was :py:data:`PIL.Image.Resampling.NEAREST` prior to version 2.5.0).
2451+
of :py:data:`Resampling.NEAREST`, :py:data:`Resampling.BOX`,
2452+
:py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`,
2453+
:py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`.
2454+
If omitted, it defaults to :py:data:`Resampling.BICUBIC`.
2455+
(was :py:data:`Resampling.NEAREST` prior to version 2.5.0).
24632456
See: :ref:`concept-filters`.
24642457
:param reducing_gap: Apply optimization by resizing the image
24652458
in two steps. First, reducing the image by integer times
@@ -2530,11 +2523,11 @@ def transform(
25302523
25312524
:param size: The output size.
25322525
:param method: The transformation method. This is one of
2533-
:py:data:`PIL.Image.Transform.EXTENT` (cut out a rectangular subregion),
2534-
:py:data:`PIL.Image.Transform.AFFINE` (affine transform),
2535-
:py:data:`PIL.Image.Transform.PERSPECTIVE` (perspective transform),
2536-
:py:data:`PIL.Image.Transform.QUAD` (map a quadrilateral to a rectangle), or
2537-
:py:data:`PIL.Image.Transform.MESH` (map a number of source quadrilaterals
2526+
:py:data:`Transform.EXTENT` (cut out a rectangular subregion),
2527+
:py:data:`Transform.AFFINE` (affine transform),
2528+
:py:data:`Transform.PERSPECTIVE` (perspective transform),
2529+
:py:data:`Transform.QUAD` (map a quadrilateral to a rectangle), or
2530+
:py:data:`Transform.MESH` (map a number of source quadrilaterals
25382531
in one operation).
25392532
25402533
It may also be an :py:class:`~PIL.Image.ImageTransformHandler`
@@ -2554,11 +2547,11 @@ def getdata(self):
25542547
return method, data
25552548
:param data: Extra data to the transformation method.
25562549
:param resample: Optional resampling filter. It can be one of
2557-
:py:data:`PIL.Image.Resampling.NEAREST` (use nearest neighbour),
2558-
:py:data:`PIL.Image.Resampling.BILINEAR` (linear interpolation in a 2x2
2559-
environment), or :py:data:`PIL.Image.BICUBIC` (cubic spline
2550+
:py:data:`Resampling.NEAREST` (use nearest neighbour),
2551+
:py:data:`Resampling.BILINEAR` (linear interpolation in a 2x2
2552+
environment), or :py:data:`Resampling.BICUBIC` (cubic spline
25602553
interpolation in a 4x4 environment). If omitted, or if the image
2561-
has mode "1" or "P", it is set to :py:data:`PIL.Image.Resampling.NEAREST`.
2554+
has mode "1" or "P", it is set to :py:data:`Resampling.NEAREST`.
25622555
See: :ref:`concept-filters`.
25632556
:param fill: If ``method`` is an
25642557
:py:class:`~PIL.Image.ImageTransformHandler` object, this is one of
@@ -2685,13 +2678,10 @@ def transpose(self, method):
26852678
"""
26862679
Transpose image (flip or rotate in 90 degree steps)
26872680
2688-
:param method: One of :py:data:`PIL.Image.Transpose.FLIP_LEFT_RIGHT`,
2689-
:py:data:`PIL.Image.Transpose.FLIP_TOP_BOTTOM`,
2690-
:py:data:`PIL.Image.Transpose.ROTATE_90`,
2691-
:py:data:`PIL.Image.Transpose.ROTATE_180`,
2692-
:py:data:`PIL.Image.Transpose.ROTATE_270`,
2693-
:py:data:`PIL.Image.Transpose.TRANSPOSE` or
2694-
:py:data:`PIL.Image.Transpose.TRANSVERSE`.
2681+
:param method: One of :py:data:`Transpose.FLIP_LEFT_RIGHT`,
2682+
:py:data:`Transpose.FLIP_TOP_BOTTOM`, :py:data:`Transpose.ROTATE_90`,
2683+
:py:data:`Transpose.ROTATE_180`, :py:data:`Transpose.ROTATE_270`,
2684+
:py:data:`Transpose.TRANSPOSE` or :py:data:`Transpose.TRANSVERSE`.
26952685
:returns: Returns a flipped or rotated copy of this image.
26962686
"""
26972687

0 commit comments

Comments
 (0)