From 8fbc870f5854a68f1750a8bee34de5d34549ed75 Mon Sep 17 00:00:00 2001 From: acidvegas Date: Wed, 28 Jun 2023 15:23:47 -0400 Subject: [PATCH] Added invert color effect --- img2irc.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/img2irc.py b/img2irc.py index 5018542..b861cfb 100644 --- a/img2irc.py +++ b/img2irc.py @@ -14,7 +14,7 @@ pull request: https://github.com/ircart/scroll/pull/3 import io try: - from PIL import Image, ImageEnhance + from PIL import Image, ImageEnhance, ImageOps except ImportError: raise SystemExit('missing required \'pillow\' library (https://pypi.org/project/pillow/)') @@ -51,13 +51,15 @@ def convert(data, max_line_len, img_width=80, palette='RGB99', enhance=False, ef raise Exception('invalid palette option') palette = palettes[palette] image = Image.open(io.BytesIO(data)) + del data if enhance: image = ImageEnhance.Contrast(image) - if effect == 'grey': + if effect == 'greyscale': image = image.convert("L") - elif effect == 'black': + elif effect == 'blackwhite': image = image.convert("1") - del data + elif effect == 'invert': + image = ImageOps.invert(image) return convert_image(image, max_line_len, img_width, palette) def convert_image(image, max_line_len, img_width, palette):