mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Set default resize sampling for I;16* images to BICUBIC
This commit is contained in:
parent
04a00d273c
commit
d33270ab51
|
@ -315,14 +315,14 @@ class TestImageResize:
|
||||||
im = im.resize((64, 64))
|
im = im.resize((64, 64))
|
||||||
assert im.size == (64, 64)
|
assert im.size == (64, 64)
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", ("L", "RGB", "I", "F"))
|
@pytest.mark.parametrize(
|
||||||
|
"mode", ("L", "RGB", "I", "I;16", "I;16L", "I;16B", "I;16N", "F")
|
||||||
|
)
|
||||||
def test_default_filter_bicubic(self, mode: str) -> None:
|
def test_default_filter_bicubic(self, mode: str) -> None:
|
||||||
im = hopper(mode)
|
im = hopper(mode)
|
||||||
assert im.resize((20, 20), Image.Resampling.BICUBIC) == im.resize((20, 20))
|
assert im.resize((20, 20), Image.Resampling.BICUBIC) == im.resize((20, 20))
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize("mode", ("1", "P", "BGR;15", "BGR;16"))
|
||||||
"mode", ("1", "P", "I;16", "I;16L", "I;16B", "BGR;15", "BGR;16")
|
|
||||||
)
|
|
||||||
def test_default_filter_nearest(self, mode: str) -> None:
|
def test_default_filter_nearest(self, mode: str) -> None:
|
||||||
im = hopper(mode)
|
im = hopper(mode)
|
||||||
assert im.resize((20, 20), Image.Resampling.NEAREST) == im.resize((20, 20))
|
assert im.resize((20, 20), Image.Resampling.NEAREST) == im.resize((20, 20))
|
||||||
|
|
|
@ -119,10 +119,11 @@ Specific WebP Feature Checks
|
||||||
API Changes
|
API Changes
|
||||||
===========
|
===========
|
||||||
|
|
||||||
TODO
|
Default resampling filter for I;16* image modes
|
||||||
^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
TODO
|
The default resampling filter for I;16, I;16L, I;16B and I;16N has been changed from
|
||||||
|
``Image.NEAREST`` to ``Image.BICUBIC``, to match the majority of modes.
|
||||||
|
|
||||||
API Additions
|
API Additions
|
||||||
=============
|
=============
|
||||||
|
|
|
@ -2278,8 +2278,8 @@ class Image:
|
||||||
:py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`,
|
:py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`,
|
||||||
:py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`.
|
:py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`.
|
||||||
If the image has mode "1" or "P", it is always set to
|
If the image has mode "1" or "P", it is always set to
|
||||||
:py:data:`Resampling.NEAREST`. If the image mode specifies a number
|
:py:data:`Resampling.NEAREST`. If the image mode is "BGR;15",
|
||||||
of bits, such as "I;16", then the default filter is
|
"BGR;16" or "BGR;24", then the default filter is
|
||||||
:py:data:`Resampling.NEAREST`. Otherwise, the default filter is
|
:py:data:`Resampling.NEAREST`. Otherwise, the default filter is
|
||||||
:py:data:`Resampling.BICUBIC`. See: :ref:`concept-filters`.
|
:py:data:`Resampling.BICUBIC`. See: :ref:`concept-filters`.
|
||||||
:param box: An optional 4-tuple of floats providing
|
:param box: An optional 4-tuple of floats providing
|
||||||
|
@ -2302,8 +2302,8 @@ class Image:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if resample is None:
|
if resample is None:
|
||||||
type_special = ";" in self.mode
|
bgr = self.mode.startswith("BGR;")
|
||||||
resample = Resampling.NEAREST if type_special else Resampling.BICUBIC
|
resample = Resampling.NEAREST if bgr else Resampling.BICUBIC
|
||||||
elif resample not in (
|
elif resample not in (
|
||||||
Resampling.NEAREST,
|
Resampling.NEAREST,
|
||||||
Resampling.BILINEAR,
|
Resampling.BILINEAR,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user