diff --git a/Tests/test_file_gd.py b/Tests/test_file_gd.py index 806532c17..8a49fd4fa 100644 --- a/Tests/test_file_gd.py +++ b/Tests/test_file_gd.py @@ -1,5 +1,7 @@ from __future__ import annotations +from io import BytesIO + import pytest from PIL import GdImageFile, UnidentifiedImageError @@ -16,6 +18,14 @@ def test_sanity() -> None: assert_image_similar_tofile(im.convert("RGB"), "Tests/images/hopper.jpg", 14) +def test_transparency() -> None: + with open(TEST_GD_FILE, "rb") as fp: + data = bytearray(fp.read()) + data[7:11] = b"\x00\x00\x00\x05" + with GdImageFile.open(BytesIO(data)) as im: + assert im.info["transparency"] == 5 + + def test_bad_mode() -> None: with pytest.raises(ValueError): GdImageFile.open(TEST_GD_FILE, "bad mode")