From fb1d56d4c4a63f822cd6387600d15d364ad4d8a5 Mon Sep 17 00:00:00 2001 From: iou1name Date: Sat, 8 May 2021 21:49:40 -0400 Subject: [PATCH] add support for LA mode images --- modules/ascii.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/ascii.py b/modules/ascii.py index fdc3f4d..6b760e3 100755 --- a/modules/ascii.py +++ b/modules/ascii.py @@ -150,7 +150,10 @@ def alpha_composite(image, color=(255, 255, 255)): """ image.load() # needed for split() background = Image.new('RGB', image.size, color) - background.paste(image, mask=image.split()[3]) # 3 is the alpha channel + if image.mode == "RGBA": + background.paste(image, mask=image.split()[3]) # 3 is the alpha channel + if image.mode == "LA": + background.paste(image, mask=image.split()[1]) # 1 is the alpha channel return background @@ -169,6 +172,8 @@ def image_to_ascii(image=None, reverse=False, brail=False, color=None,**kwargs): image = alpha_composite(image).convert("RGB") if image.mode == "L": image = image.convert("RGB") + if image.mode == "LA": + image = alpha_composite(image).convert("RGB") image = scale_image(image)