Skip to content

Commit 63987b7

Browse files
committed
Set mode to L if palette is missing
1 parent 50e9a92 commit 63987b7

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Tests/test_file_tga.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ def test_small_palette(tmp_path: Path) -> None:
133133
assert reloaded.getpalette() == colors
134134

135135

136+
def test_missing_palette() -> None:
137+
with Image.open("Tests/images/dilation4.lut") as im:
138+
assert im.mode == "L"
139+
140+
136141
def test_save_wrong_mode(tmp_path: Path) -> None:
137142
im = hopper("PA")
138143
out = str(tmp_path / "temp.tga")

src/PIL/TgaImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _open(self) -> None:
8585
elif depth == 16:
8686
self._mode = "LA"
8787
elif imagetype in (1, 9):
88-
self._mode = "P"
88+
self._mode = "P" if colormaptype else "L"
8989
elif imagetype in (2, 10):
9090
self._mode = "RGB"
9191
if depth == 32:

0 commit comments

Comments
 (0)