diff --git a/Tests/images/bmp/q/rgba32h56.bmp b/Tests/images/bmp/q/rgba32h56.bmp new file mode 100644 index 000000000..343baa330 Binary files /dev/null and b/Tests/images/bmp/q/rgba32h56.bmp differ diff --git a/Tests/test_bmp_reference.py b/Tests/test_bmp_reference.py index 5398664b8..a5a4283e3 100644 --- a/Tests/test_bmp_reference.py +++ b/Tests/test_bmp_reference.py @@ -45,6 +45,7 @@ def test_questionable() -> None: "pal8rletrns.bmp", "rgb32bf-xbgr.bmp", "rgb32h52.bmp", + "rgba32h56.bmp", ] for f in get_files("q"): try: diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py index dd8c06f4d..82a9c47db 100644 --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -53,7 +53,7 @@ def _accept(prefix: bytes) -> bool: def _dib_accept(prefix): - return i32(prefix) in [12, 40, 52, 64, 108, 124] + return i32(prefix) in [12, 40, 52, 56, 64, 108, 124] # ============================================================================= @@ -95,7 +95,7 @@ class BmpImageFile(ImageFile.ImageFile): # --------------------------------------------- Windows Bitmap v2 to v5 # v3, OS/2 v2, v4, v5 - elif file_info["header_size"] in (40, 52, 64, 108, 124): + elif file_info["header_size"] in (40, 52, 56, 64, 108, 124): file_info["y_flip"] = header_data[7] == 0xFF file_info["direction"] = 1 if file_info["y_flip"] else -1 file_info["width"] = i32(header_data, 0)