Merge pull request #8733 from radarhere/tuple

This commit is contained in:
Hugo van Kemenade 2025-02-06 13:19:29 +02:00 committed by GitHub
commit c73796dc1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 18 additions and 26 deletions

View File

@ -19,7 +19,7 @@ except ImportError:
class TestColorLut3DCoreAPI:
def generate_identity_table(
self, channels: int, size: int | tuple[int, int, int]
) -> tuple[int, int, int, int, list[float]]:
) -> tuple[int, tuple[int, int, int], list[float]]:
if isinstance(size, tuple):
size_1d, size_2d, size_3d = size
else:
@ -39,9 +39,7 @@ class TestColorLut3DCoreAPI:
]
return (
channels,
size_1d,
size_2d,
size_3d,
(size_1d, size_2d, size_3d),
[item for sublist in table for item in sublist],
)
@ -89,21 +87,21 @@ class TestColorLut3DCoreAPI:
with pytest.raises(ValueError, match=r"size1D \* size2D \* size3D"):
im.im.color_lut_3d(
"RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, 0] * 7
"RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), [0, 0, 0] * 7
)
with pytest.raises(ValueError, match=r"size1D \* size2D \* size3D"):
im.im.color_lut_3d(
"RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, 0] * 9
"RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), [0, 0, 0] * 9
)
with pytest.raises(TypeError):
im.im.color_lut_3d(
"RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, "0"] * 8
"RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), [0, 0, "0"] * 8
)
with pytest.raises(TypeError):
im.im.color_lut_3d("RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, 16)
im.im.color_lut_3d("RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), 16)
@pytest.mark.parametrize(
"lut_mode, table_channels, table_size",
@ -264,7 +262,7 @@ class TestColorLut3DCoreAPI:
assert_image_equal(
Image.merge('RGB', im.split()[::-1]),
im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR,
3, 2, 2, 2, [
3, (2, 2, 2), [
0, 0, 0, 0, 0, 1,
0, 1, 0, 0, 1, 1,
@ -286,7 +284,7 @@ class TestColorLut3DCoreAPI:
# fmt: off
transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR,
3, 2, 2, 2,
3, (2, 2, 2),
[
-1, -1, -1, 2, -1, -1,
-1, 2, -1, 2, 2, -1,
@ -307,7 +305,7 @@ class TestColorLut3DCoreAPI:
# fmt: off
transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR,
3, 2, 2, 2,
3, (2, 2, 2),
[
-3, -3, -3, 5, -3, -3,
-3, 5, -3, 5, 5, -3,

View File

@ -598,8 +598,6 @@ class Color3DLUT(MultibandFilter):
self.mode or image.mode,
Image.Resampling.BILINEAR,
self.channels,
self.size[0],
self.size[1],
self.size[2],
self.size,
self.table,
)

View File

@ -647,8 +647,7 @@ class FreeTypeFont:
kwargs.get("stroke_filled", False),
anchor,
ink,
start[0],
start[1],
start,
)
def font_variant(

View File

@ -816,8 +816,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
optimize,
info.get("keep_rgb", False),
info.get("streamtype", 0),
dpi[0],
dpi[1],
dpi,
subsampling,
info.get("restart_marker_blocks", 0),
info.get("restart_marker_rows", 0),

View File

@ -223,8 +223,7 @@ def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
# Setup the WebP animation encoder
enc = _webp.WebPAnimEncoder(
im.size[0],
im.size[1],
im.size,
background,
loop,
minimize_size,

View File

@ -31,8 +31,7 @@ class Font:
stroke_filled: bool,
anchor: str | None,
foreground_ink_long: int,
x_start: float,
y_start: float,
start: tuple[float, float],
/,
) -> tuple[_imaging.ImagingCore, tuple[int, int]]: ...
def getsize(

View File

@ -866,7 +866,7 @@ _color_lut_3d(ImagingObject *self, PyObject *args) {
if (!PyArg_ParseTuple(
args,
"siiiiiO:color_lut_3d",
"sii(iii)O:color_lut_3d",
&mode,
&filter,
&table_channels,

View File

@ -854,7 +854,7 @@ font_render(FontObject *self, PyObject *args) {
if (!PyArg_ParseTuple(
args,
"OO|zzOzfpzLffO:render",
"OO|zzOzfpzL(ff):render",
&string,
&fill,
&mode,

View File

@ -164,7 +164,7 @@ _anim_encoder_new(PyObject *self, PyObject *args) {
if (!PyArg_ParseTuple(
args,
"iiIiiiiii",
"(ii)Iiiiiii",
&width,
&height,
&bgcolor,

View File

@ -1097,7 +1097,7 @@ PyImaging_JpegEncoderNew(PyObject *self, PyObject *args) {
if (!PyArg_ParseTuple(
args,
"ss|nnnnpnnnnnnOz#y#y#",
"ss|nnnnpn(nn)nnnOz#y#y#",
&mode,
&rawmode,
&quality,