mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Use palette when loading
This commit is contained in:
parent
50e9a92c98
commit
21e5d5d082
|
@ -38,6 +38,17 @@ def test_black_and_white() -> None:
|
|||
assert im.size == (16, 16)
|
||||
|
||||
|
||||
def test_palette(tmp_path: Path) -> None:
|
||||
temp_file = str(tmp_path / "temp.ico")
|
||||
|
||||
im = Image.new("P", (16, 16))
|
||||
im.save(temp_file)
|
||||
|
||||
with Image.open(temp_file) as reloaded:
|
||||
assert reloaded.mode == "P"
|
||||
assert reloaded.palette is not None
|
||||
|
||||
|
||||
def test_invalid_file() -> None:
|
||||
with open("Tests/images/flower.jpg", "rb") as fp:
|
||||
with pytest.raises(SyntaxError):
|
||||
|
|
|
@ -329,6 +329,8 @@ class IcoImageFile(ImageFile.ImageFile):
|
|||
self.im = im.im
|
||||
self.pyaccess = None
|
||||
self._mode = im.mode
|
||||
if im.palette:
|
||||
self.palette = im.palette
|
||||
if im.size != self.size:
|
||||
warnings.warn("Image was not the expected size")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user