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

View File

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

View File

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

View File

@ -816,8 +816,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
optimize, optimize,
info.get("keep_rgb", False), info.get("keep_rgb", False),
info.get("streamtype", 0), info.get("streamtype", 0),
dpi[0], dpi,
dpi[1],
subsampling, subsampling,
info.get("restart_marker_blocks", 0), info.get("restart_marker_blocks", 0),
info.get("restart_marker_rows", 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 # Setup the WebP animation encoder
enc = _webp.WebPAnimEncoder( enc = _webp.WebPAnimEncoder(
im.size[0], im.size,
im.size[1],
background, background,
loop, loop,
minimize_size, minimize_size,

View File

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

View File

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

View File

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

View File

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

View File

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