mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Raise an error if map depth is unknown
This commit is contained in:
parent
63987b7aba
commit
818500b329
BIN
Tests/images/p_8.tga
Normal file
BIN
Tests/images/p_8.tga
Normal file
Binary file not shown.
|
@ -7,7 +7,7 @@ from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image, UnidentifiedImageError
|
||||||
|
|
||||||
from .helper import assert_image_equal, assert_image_equal_tofile, hopper
|
from .helper import assert_image_equal, assert_image_equal_tofile, hopper
|
||||||
|
|
||||||
|
@ -65,6 +65,11 @@ def test_sanity(mode, tmp_path: Path) -> None:
|
||||||
roundtrip(original_im)
|
roundtrip(original_im)
|
||||||
|
|
||||||
|
|
||||||
|
def test_palette_depth_8(tmp_path: Path) -> None:
|
||||||
|
with pytest.raises(UnidentifiedImageError):
|
||||||
|
Image.open("Tests/images/p_8.tga")
|
||||||
|
|
||||||
|
|
||||||
def test_palette_depth_16(tmp_path: Path) -> None:
|
def test_palette_depth_16(tmp_path: Path) -> None:
|
||||||
with Image.open("Tests/images/p_16.tga") as im:
|
with Image.open("Tests/images/p_16.tga") as im:
|
||||||
assert_image_equal_tofile(im.convert("RGB"), "Tests/images/p_16.png")
|
assert_image_equal_tofile(im.convert("RGB"), "Tests/images/p_16.png")
|
||||||
|
|
|
@ -128,6 +128,9 @@ class TgaImageFile(ImageFile.ImageFile):
|
||||||
self.palette = ImagePalette.raw(
|
self.palette = ImagePalette.raw(
|
||||||
"BGRA", b"\0" * 4 * start + self.fp.read(4 * size)
|
"BGRA", b"\0" * 4 * start + self.fp.read(4 * size)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
msg = "unknown TGA map depth"
|
||||||
|
raise SyntaxError(msg)
|
||||||
|
|
||||||
# setup tile descriptor
|
# setup tile descriptor
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user