Skip to content

Commit 7cb074f

Browse files
authored
Test GD transparency (#9196)
2 parents 10c6745 + b90fe80 commit 7cb074f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Tests/test_file_gd.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
from io import BytesIO
4+
35
import pytest
46

57
from PIL import GdImageFile, UnidentifiedImageError
@@ -16,6 +18,14 @@ def test_sanity() -> None:
1618
assert_image_similar_tofile(im.convert("RGB"), "Tests/images/hopper.jpg", 14)
1719

1820

21+
def test_transparency() -> None:
22+
with open(TEST_GD_FILE, "rb") as fp:
23+
data = bytearray(fp.read())
24+
data[7:11] = b"\x00\x00\x00\x05"
25+
with GdImageFile.open(BytesIO(data)) as im:
26+
assert im.info["transparency"] == 5
27+
28+
1929
def test_bad_mode() -> None:
2030
with pytest.raises(ValueError):
2131
GdImageFile.open(TEST_GD_FILE, "bad mode")

0 commit comments

Comments
 (0)