From 22c2d78980abea8232f172477a105c4b25869879 Mon Sep 17 00:00:00 2001 From: acidvegas Date: Wed, 28 Jun 2023 15:12:45 -0400 Subject: [PATCH] Added greyscale/blackwhite effects to img2irc (not implemented into scroll yet) --- img2irc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/img2irc.py b/img2irc.py index 93a9ca3..36cb987 100644 --- a/img2irc.py +++ b/img2irc.py @@ -45,13 +45,17 @@ palettes = { 0xbcbcbc, 0xe2e2e2, 0xffffff] } -def convert(data, max_line_len, img_width=80, palette='RGB99', enhance=False): +def convert(data, max_line_len, img_width=80, palette='RGB99', enhance=False, effect=None): if palette not in palettes: raise Exception('invalid palette option') palette = palettes[palette] image = Image.open(io.BytesIO(data)) if enhance: image = ImageEnhance.Contrast(image) + if effect == 'grey': + image = image.convert("L") + elif effect == 'black': + image = image.convert("1") del data return convert_image(image, max_line_len, img_width, palette)