Skip to content

Commit

Permalink
Merge pull request #1 from radarhere/p2pa_images_conversion
Browse files Browse the repository at this point in the history
Only test alpha channel values
  • Loading branch information
RedShy committed May 28, 2022
2 parents 84da709 + b0bc74a commit 7f39a21
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Tests/test_image_convert.py
Expand Up @@ -222,18 +222,18 @@ def test_p_la():
assert_image_similar(alpha, comparable, 5)


def test_p_pa():
def test_p2pa_alpha():
with Image.open("Tests/images/tiny.png") as im:
assert im.mode == "P"

im_pa = im.convert("PA")
assert im_pa.mode == "PA"
assert im_pa.mode == "PA"

assert (
im_pa.tobytes() == b"\x00\x00\x00\x00\x08\xff\x04\xff\x00\x00\x00\x00"
b"\x06\xff\x07\xff\x00\x00\x00\x00\x02\xff\x03\xff\x00"
b"\x00\x00\x00\x01\xff\x05\xff"
)
im_a = im_pa.getchannel("A")
for x in range(4):
alpha = 255 if x > 1 else 0
for y in range(4):
assert im_a.getpixel((x, y)) == alpha


def test_matrix_illegal_conversion():
Expand Down

0 comments on commit 7f39a21

Please sign in to comment.