scroll

- irc bot to play ascii art
git clone git://git.acid.vegas/scroll.git
Log | Files | Refs | Archive | README | LICENSE

commit 8fbc870f5854a68f1750a8bee34de5d34549ed75
parent a21e7e2f6a41af651c3f260ac5ad0f88a22d2da7
Author: acidvegas <acid.vegas@acid.vegas>
Date: Wed, 28 Jun 2023 15:23:47 -0400

Added invert color effect

Diffstat:
Mimg2irc.py | 10++++++----

1 file changed, 6 insertions(+), 4 deletions(-)

diff --git 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):