Allow size argument to resize() to be a list

This commit is contained in:
Andrew Murray 2024-07-04 15:13:03 +10:00
parent 776dd63f33
commit 936012e861
2 changed files with 5 additions and 4 deletions

View File

@ -285,14 +285,14 @@ class TestReducingGapResize:
class TestImageResize:
def test_resize(self) -> None:
def resize(mode: str, size: tuple[int, int]) -> None:
def resize(mode: str, size: tuple[int, int] | list[int]) -> None:
out = hopper(mode).resize(size)
assert out.mode == mode
assert out.size == size
assert out.size == tuple(size)
for mode in "1", "P", "L", "RGB", "I", "F":
resize(mode, (112, 103))
resize(mode, (188, 214))
resize(mode, [188, 214])
# Test unknown resampling filter
with hopper() as im:

View File

@ -2203,7 +2203,7 @@ class Image:
def resize(
self,
size: tuple[int, int],
size: tuple[int, int] | list[int],
resample: int | None = None,
box: tuple[float, float, float, float] | None = None,
reducing_gap: float | None = None,
@ -2276,6 +2276,7 @@ class Image:
if box is None:
box = (0, 0) + self.size
size = tuple(size)
if self.size == size and box == (0, 0) + self.size:
return self.copy()