mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
For special image modes, revert default resize resampling to NEAREST
This commit is contained in:
parent
9b6fe1b039
commit
7c0344bb99
|
@ -250,3 +250,7 @@ class TestImageResize:
|
|||
for mode in "1", "P":
|
||||
im = hopper(mode)
|
||||
assert im.resize((20, 20), Image.NEAREST) == im.resize((20, 20))
|
||||
|
||||
for mode in "I;16", "I;16L", "I;16B", "BGR;15", "BGR;16":
|
||||
im = hopper(mode)
|
||||
assert im.resize((20, 20), Image.NEAREST) == im.resize((20, 20))
|
||||
|
|
|
@ -1849,7 +1849,7 @@ class Image:
|
|||
min(self.size[1], math.ceil(box[3] + support_y)),
|
||||
)
|
||||
|
||||
def resize(self, size, resample=BICUBIC, box=None, reducing_gap=None):
|
||||
def resize(self, size, resample=None, box=None, reducing_gap=None):
|
||||
"""
|
||||
Returns a resized copy of this image.
|
||||
|
||||
|
@ -1859,9 +1859,11 @@ class Image:
|
|||
one of :py:data:`PIL.Image.NEAREST`, :py:data:`PIL.Image.BOX`,
|
||||
:py:data:`PIL.Image.BILINEAR`, :py:data:`PIL.Image.HAMMING`,
|
||||
:py:data:`PIL.Image.BICUBIC` or :py:data:`PIL.Image.LANCZOS`.
|
||||
Default filter is :py:data:`PIL.Image.BICUBIC`.
|
||||
If the image has mode "1" or "P", it is
|
||||
always set to :py:data:`PIL.Image.NEAREST`.
|
||||
If the image has mode "1" or "P", it is always set to
|
||||
:py:data:`PIL.Image.NEAREST`.
|
||||
If the image mode specifies a number of bits, such as "I;16", then the
|
||||
default filter is :py:data:`PIL.Image.NEAREST`.
|
||||
Otherwise, the default filter is :py:data:`PIL.Image.BICUBIC`.
|
||||
See: :ref:`concept-filters`.
|
||||
:param box: An optional 4-tuple of floats providing
|
||||
the source image region to be scaled.
|
||||
|
@ -1882,7 +1884,10 @@ class Image:
|
|||
:returns: An :py:class:`~PIL.Image.Image` object.
|
||||
"""
|
||||
|
||||
if resample not in (NEAREST, BILINEAR, BICUBIC, LANCZOS, BOX, HAMMING):
|
||||
if resample is None:
|
||||
type_special = ";" in self.mode
|
||||
resample = NEAREST if type_special else BICUBIC
|
||||
elif resample not in (NEAREST, BILINEAR, BICUBIC, LANCZOS, BOX, HAMMING):
|
||||
message = f"Unknown resampling filter ({resample})."
|
||||
|
||||
filters = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user