def test_paletted_image_not_transparent(self): img = new('P', (256, 256)) assert img_has_transparency(img) == 0
def test_paletted_image_transparent(self): img = new("P", (256, 256), 0) img.save("test1.png", "PNG", transparency="\x00") img = iopen("test1.png", "r") assert img_has_transparency(img)
def test_partially_transparent(self): img = new("RGBA", (256, 256)) draw = ImageDraw.Draw(img) draw.ellipse((96, 96, 160, 160), fill=(255, 0, 0)) assert img_has_transparency(img) > 0
def test_fully_transparent(self): img = new('RGBA', (256, 256)) assert img_has_transparency(img) == -1
def test_not_transparent(self): img = new("RGB", (256, 256), "red") assert img_has_transparency(img) == 0