Merge pull request #5429 from radarhere/ico

Use bpp from ICO header
This commit is contained in:
Hugo van Kemenade 2021-04-25 12:07:38 +03:00 committed by GitHub
commit 6461dd63b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

View File

@ -18,6 +18,12 @@ def test_sanity():
assert im.get_format_mimetype() == "image/x-icon"
def test_black_and_white():
with Image.open("Tests/images/black_and_white.ico") as im:
assert im.mode == "RGBA"
assert im.size == (16, 16)
def test_invalid_file():
with open("Tests/images/flower.jpg", "rb") as fp:
with pytest.raises(SyntaxError):

View File

@ -190,13 +190,7 @@ class IcoFile:
im.tile[0] = d, (0, 0) + im.size, o, a
# figure out where AND mask image starts
mode = a[0]
bpp = 8
for k, v in BmpImagePlugin.BIT2MODE.items():
if mode == v[1]:
bpp = k
break
bpp = header["bpp"]
if 32 == bpp:
# 32-bit color depth icon image allows semitransparent areas
# PIL's DIB format ignores transparency bits, recover them.