mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-13 01:23:18 +03:00
Merge pull request #5411 from radarhere/resize_default
For special image modes, revert default resize resampling to NEAREST
This commit is contained in:
commit
d2e73b0304
|
@ -250,3 +250,7 @@ class TestImageResize:
|
||||||
for mode in "1", "P":
|
for mode in "1", "P":
|
||||||
im = hopper(mode)
|
im = hopper(mode)
|
||||||
assert im.resize((20, 20), Image.NEAREST) == im.resize((20, 20))
|
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)),
|
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.
|
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`,
|
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.BILINEAR`, :py:data:`PIL.Image.HAMMING`,
|
||||||
:py:data:`PIL.Image.BICUBIC` or :py:data:`PIL.Image.LANCZOS`.
|
: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
|
||||||
If the image has mode "1" or "P", it is
|
:py:data:`PIL.Image.NEAREST`.
|
||||||
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`.
|
See: :ref:`concept-filters`.
|
||||||
:param box: An optional 4-tuple of floats providing
|
:param box: An optional 4-tuple of floats providing
|
||||||
the source image region to be scaled.
|
the source image region to be scaled.
|
||||||
|
@ -1882,7 +1884,10 @@ class Image:
|
||||||
:returns: An :py:class:`~PIL.Image.Image` object.
|
: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})."
|
message = f"Unknown resampling filter ({resample})."
|
||||||
|
|
||||||
filters = [
|
filters = [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user