diff --git a/Tests/test_file_ico.py b/Tests/test_file_ico.py index 3fcd5c61f0d..afb17b1afad 100644 --- a/Tests/test_file_ico.py +++ b/Tests/test_file_ico.py @@ -71,6 +71,19 @@ def test_save_to_bytes(): ) +def test_getpixel(tmp_path): + temp_file = str(tmp_path / "temp.ico") + + im = hopper() + im.save(temp_file, "ico", sizes=[(32, 32), (64, 64)]) + + with Image.open(temp_file) as reloaded: + reloaded.load() + reloaded.size = (32, 32) + + assert reloaded.getpixel((0, 0)) == (18, 20, 62) + + def test_no_duplicates(tmp_path): temp_file = str(tmp_path / "temp.ico") temp_file2 = str(tmp_path / "temp2.ico") diff --git a/src/PIL/IcoImagePlugin.py b/src/PIL/IcoImagePlugin.py index 17b9855a0a5..93b9dfdea7b 100644 --- a/src/PIL/IcoImagePlugin.py +++ b/src/PIL/IcoImagePlugin.py @@ -327,6 +327,7 @@ def load(self): # if tile is PNG, it won't really be loaded yet im.load() self.im = im.im + self.pyaccess = None self.mode = im.mode if im.size != self.size: warnings.warn("Image was not the expected size")