mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Test GD transparency (#9196)
This commit is contained in:
		
						commit
						7cb074f095
					
				| 
						 | 
					@ -1,5 +1,7 @@
 | 
				
			||||||
from __future__ import annotations
 | 
					from __future__ import annotations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from io import BytesIO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pytest
 | 
					import pytest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from PIL import GdImageFile, UnidentifiedImageError
 | 
					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)
 | 
					        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:
 | 
					def test_bad_mode() -> None:
 | 
				
			||||||
    with pytest.raises(ValueError):
 | 
					    with pytest.raises(ValueError):
 | 
				
			||||||
        GdImageFile.open(TEST_GD_FILE, "bad mode")
 | 
					        GdImageFile.open(TEST_GD_FILE, "bad mode")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user