Skip to content

Commit f543b03

Browse files
authored
Merge pull request #7798 from radarhere/ico
2 parents e093663 + 21e5d5d commit f543b03

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Tests/test_file_ico.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ def test_black_and_white() -> None:
3838
assert im.size == (16, 16)
3939

4040

41+
def test_palette(tmp_path: Path) -> None:
42+
temp_file = str(tmp_path / "temp.ico")
43+
44+
im = Image.new("P", (16, 16))
45+
im.save(temp_file)
46+
47+
with Image.open(temp_file) as reloaded:
48+
assert reloaded.mode == "P"
49+
assert reloaded.palette is not None
50+
51+
4152
def test_invalid_file() -> None:
4253
with open("Tests/images/flower.jpg", "rb") as fp:
4354
with pytest.raises(SyntaxError):

src/PIL/IcoImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ def load(self):
329329
self.im = im.im
330330
self.pyaccess = None
331331
self._mode = im.mode
332+
if im.palette:
333+
self.palette = im.palette
332334
if im.size != self.size:
333335
warnings.warn("Image was not the expected size")
334336

0 commit comments

Comments
 (0)