From 15307955f747637f03b8d1ed1d880703532d994f Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 26 Apr 2025 15:56:15 +1000 Subject: [PATCH] Use IcoFile sizes method --- Tests/test_file_cur.py | 8 ++++---- src/PIL/CurImagePlugin.py | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Tests/test_file_cur.py b/Tests/test_file_cur.py index 586e36c53..c23bb6a1a 100644 --- a/Tests/test_file_cur.py +++ b/Tests/test_file_cur.py @@ -21,7 +21,7 @@ def test_deerstalker() -> None: def test_posy_link(): with Image.open("Tests/images/cur/posy_link.cur") as im: assert im.size == (128, 128) - assert im.info["sizes"] == [(128, 128), (96, 96), (64, 64), (48, 48), (32, 32)] + assert im.info["sizes"] == {(128, 128), (96, 96), (64, 64), (48, 48), (32, 32)} assert im.info["hotspots"] == [(25, 7), (18, 5), (12, 3), (9, 2), (5, 1)] # check some pixel colors assert im.getpixel((0, 0)) == (0, 0, 0, 0) @@ -89,7 +89,7 @@ def test_save_win98_arrow(): # check default save params with Image.open(output) as im2: assert im2.size == (32, 32) - assert im2.info["sizes"] == [(32, 32), (24, 24), (16, 16)] + assert im2.info["sizes"] == {(32, 32), (24, 24), (16, 16)} assert im2.info["hotspots"] == [(0, 0), (0, 0), (0, 0)] @@ -112,7 +112,7 @@ def test_save_posy_link(): # and sizes/hotspots are correct with Image.open(output, formats=["CUR"]) as im2: assert (128, 128) == im2.size - assert sizes == im2.info["sizes"] + assert set(sizes) == im2.info["sizes"] with BytesIO() as output: im.save(output, sizes=sizes[3:], hotspots=hotspots[3:], format="CUR") @@ -121,7 +121,7 @@ def test_save_posy_link(): # and sizes/hotspots are correct with Image.open(output, formats=["CUR"]) as im2: assert (48, 48) == im2.size - assert sizes[3:] == im2.info["sizes"] + assert set(sizes[3:]) == im2.info["sizes"] # make sure error is thrown when size and hotspot len's # don't match diff --git a/src/PIL/CurImagePlugin.py b/src/PIL/CurImagePlugin.py index 3a897171e..1a9ddf5ea 100644 --- a/src/PIL/CurImagePlugin.py +++ b/src/PIL/CurImagePlugin.py @@ -187,9 +187,6 @@ class CurFile(IcoImagePlugin.IcoFile): self.entry = sorted(self.entry, key=lambda x: x.square, reverse=True) - def sizes(self) -> list[tuple[int, int]]: - return [(h.width, h.height) for h in self.entry] - def hotspots(self) -> list[tuple[int, int]]: return [(h.x_hotspot, h.y_hotspot) for h in self.entry]