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)