diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py index 1eaff0c7df0..5b9ab0d9715 100644 --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -5,7 +5,7 @@ import pytest -from PIL import BmpImagePlugin, Image +from PIL import _binary, BmpImagePlugin, Image from .helper import ( assert_image_equal, @@ -128,6 +128,29 @@ def test_load_dib() -> None: assert_image_equal_tofile(im, "Tests/images/clipboard_target.png") +@pytest.mark.parametrize( + "header_size, path", + ( + (12, "g/pal8os2.bmp"), + (40, "g/pal1.bmp"), + (52, "q/rgb32h52.bmp"), + (56, "q/rgba32h56.bmp"), + (64, "q/pal8os2v2.bmp"), + (108, "g/pal8v4.bmp"), + (124, "g/pal8v5.bmp"), + ), +) +def test_dib_header_size(header_size, path): + image_path = "Tests/images/bmp/" + path + with open(image_path, "rb") as fp: + data = fp.read()[14:] + assert _binary.i32le(data) == header_size + + dib = io.BytesIO(data) + with Image.open(dib) as im: + im.load() + + def test_save_dib(tmp_path: Path) -> None: outfile = str(tmp_path / "temp.dib")