File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff 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+
4152def test_invalid_file () -> None :
4253 with open ("Tests/images/flower.jpg" , "rb" ) as fp :
4354 with pytest .raises (SyntaxError ):
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments