diff --git a/Tests/images/imageops_pad_h_0.jpg b/Tests/images/imageops_pad_h_0.jpg index f9fcb1cdb..7afbbb96a 100644 Binary files a/Tests/images/imageops_pad_h_0.jpg and b/Tests/images/imageops_pad_h_0.jpg differ diff --git a/Tests/images/imageops_pad_h_1.jpg b/Tests/images/imageops_pad_h_1.jpg index 4b9b9ebc4..b9bf8a49a 100644 Binary files a/Tests/images/imageops_pad_h_1.jpg and b/Tests/images/imageops_pad_h_1.jpg differ diff --git a/Tests/images/imageops_pad_h_2.jpg b/Tests/images/imageops_pad_h_2.jpg index 2c8224892..7e0eb9599 100644 Binary files a/Tests/images/imageops_pad_h_2.jpg and b/Tests/images/imageops_pad_h_2.jpg differ diff --git a/Tests/images/imageops_pad_v_0.jpg b/Tests/images/imageops_pad_v_0.jpg index caf435796..73a96c86c 100644 Binary files a/Tests/images/imageops_pad_v_0.jpg and b/Tests/images/imageops_pad_v_0.jpg differ diff --git a/Tests/images/imageops_pad_v_1.jpg b/Tests/images/imageops_pad_v_1.jpg index 4a6698e91..04545f817 100644 Binary files a/Tests/images/imageops_pad_v_1.jpg and b/Tests/images/imageops_pad_v_1.jpg differ diff --git a/Tests/images/imageops_pad_v_2.jpg b/Tests/images/imageops_pad_v_2.jpg index 792952bcd..f3e399d7b 100644 Binary files a/Tests/images/imageops_pad_v_2.jpg and b/Tests/images/imageops_pad_v_2.jpg differ diff --git a/docs/releasenotes/7.0.0.rst b/docs/releasenotes/7.0.0.rst index 89a0c5a4e..ed887f082 100644 --- a/docs/releasenotes/7.0.0.rst +++ b/docs/releasenotes/7.0.0.rst @@ -47,12 +47,16 @@ Setting the size of TIFF images Setting the size of a TIFF image directly (eg. ``im.size = (256, 256)``) throws an error. Use ``Image.resize`` instead. -Default resize resampling filter -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Default resampling filter +^^^^^^^^^^^^^^^^^^^^^^^^^ -The default resampling filter for the ``Image.resize`` method is changed to -high-quality convolution ``Image.BICUBIC`` instead of ``Image.NEAREST``. +The default resampling filter is changed to high-quality convolution +``Image.BICUBIC`` instead of ``Image.NEAREST`` for the :py:meth:`~PIL.Image.Image.resize` +method and for :py:meth:`~PIL.ImageOps.pad``, :py:meth:`~PIL.ImageOps.scale`` +and :py:meth:`~PIL.ImageOps.fit`` functions. ``Image.NEAREST`` is still always used for images in "P" and "1" modes. +See :ref:`concept-filters` to learn the difference. In short, +``Image.NEAREST`` is a very fast and simple but low-quality filter. API Changes diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index 3ffe50806..3a6dabf5e 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -221,7 +221,7 @@ def colorize(image, black, white, mid=None, blackpoint=0, whitepoint=255, midpoi return _lut(image, red + green + blue) -def pad(image, size, method=Image.NEAREST, color=None, centering=(0.5, 0.5)): +def pad(image, size, method=Image.BICUBIC, color=None, centering=(0.5, 0.5)): """ Returns a sized and padded version of the image, expanded to fill the requested aspect ratio and size. @@ -230,7 +230,7 @@ def pad(image, size, method=Image.NEAREST, color=None, centering=(0.5, 0.5)): :param size: The requested output size in pixels, given as a (width, height) tuple. :param method: What resampling method to use. Default is - :py:attr:`PIL.Image.NEAREST`. + :py:attr:`PIL.Image.BICUBIC`. See :ref:`concept-filters`. :param color: The background color of the padded image. :param centering: Control the position of the original image within the padded version. @@ -280,7 +280,7 @@ def crop(image, border=0): return image.crop((left, top, image.size[0] - right, image.size[1] - bottom)) -def scale(image, factor, resample=Image.NEAREST): +def scale(image, factor, resample=Image.BICUBIC): """ Returns a rescaled image by a specific factor given in parameter. A factor greater than 1 expands the image, between 0 and 1 contracts the @@ -288,8 +288,8 @@ def scale(image, factor, resample=Image.NEAREST): :param image: The image to rescale. :param factor: The expansion factor, as a float. - :param resample: An optional resampling filter. Same values possible as - in the PIL.Image.resize function. + :param resample: What resampling method to use. Default is + :py:attr:`PIL.Image.BICUBIC`. See :ref:`concept-filters`. :returns: An :py:class:`~PIL.Image.Image` object. """ if factor == 1: @@ -363,7 +363,7 @@ def expand(image, border=0, fill=0): return out -def fit(image, size, method=Image.NEAREST, bleed=0.0, centering=(0.5, 0.5)): +def fit(image, size, method=Image.BICUBIC, bleed=0.0, centering=(0.5, 0.5)): """ Returns a sized and cropped version of the image, cropped to the requested aspect ratio and size. @@ -374,7 +374,7 @@ def fit(image, size, method=Image.NEAREST, bleed=0.0, centering=(0.5, 0.5)): :param size: The requested output size in pixels, given as a (width, height) tuple. :param method: What resampling method to use. Default is - :py:attr:`PIL.Image.NEAREST`. + :py:attr:`PIL.Image.BICUBIC`. See :ref:`concept-filters`. :param bleed: Remove a border around the outside of the image from all four edges. The value is a decimal percentage (use 0.01 for one percent). The default value is 0 (no border).