scroll

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

commit 89dd0942fbbc8a318135f89bd0628c79477c4d02
parent 03cd2c405be106f3e5feac97099e1ae3020c97a5
Author: acidvegas <acid.vegas@acid.vegas>
Date: Wed, 28 Jun 2023 15:57:58 -0400

Added blur and smooth effects

Diffstat:
MREADME.md | 26+++++++++++++-------------
Mimg2irc.py | 14+++++++++-----

2 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/README.md b/README.md
@@ -31,19 +31,19 @@ Designed to be portable, there is no API key needed, no local art files needed, 
 **NOTE**: The sync & settings commands are admin only! `admin` is a *nick!user@host* mask defined in [scroll.py](https://github.com/ircart/scroll/blob/master/scroll.py)
 
 ## Settings
-| Setting          | Type         | Default | Description                                                          |
-| ---------------- | ------------ | ------------------------------------------------------------------------------ |
-| `flood`          | int or float | delay between each command                                                     |
-| `ignore`         | str          | directories to ignore in `.ascii random` *(comma seperated list, no spaces)*   |
-| `lines`          | int          | max lines outside of #scroll                                                   |
-| `msg`            | int or float | delay between each message sent                                                |
-| `paste`          | boolean      | enable or disable `.ascii play`                                                |
-| `png_brightness` | int or float | increase or decrease brightness for `.ascii img` output                        |
-| `png_contrast`   | int or float | increase or decrease contrast   for `.ascii img` output                        |
-| `png_effect`     | str          | change the effect for `.ascii img` output *(greyscale, blackwhite, or invert)* |
-| `png_palette`    | str          | palette option for `.ascii img` output *(RGB99 or RGB88)*                      |
-| `png_width`      | int          | maximum width for `.ascii img` output                                          |
-| `results`        | int          | max results to return in `.ascii search`                                       |
+| Setting          | Type         | Description                                                                                  |
+| ---------------- | ------------ | -------------------------------------------------------------------------------------------- |
+| `flood`          | int or float | delay between each command                                                                   |
+| `ignore`         | str          | directories to ignore in `.ascii random` *(comma seperated list, no spaces)*                 |
+| `lines`          | int          | max lines outside of #scroll                                                                 |
+| `msg`            | int or float | delay between each message sent                                                              |
+| `paste`          | boolean      | enable or disable `.ascii play`                                                              |
+| `png_brightness` | int or float | increase or decrease brightness for `.ascii img` output                                      |
+| `png_contrast`   | int or float | increase or decrease contrast   for `.ascii img` output                                      |
+| `png_effect`     | str          | change the effect for `.ascii img` output *(blackwhite, blue, greyscale, invert, or smooth)* |
+| `png_palette`    | str          | palette option for `.ascii img` output *(RGB99 or RGB88)*                                    |
+| `png_width`      | int          | maximum width for `.ascii img` output                                                        |
+| `results`        | int          | max results to return in `.ascii search`                                                     |
 
 **NOTE**: Setting **0** to `png_brightness`, `png_contrast`, or `png_effect` will disable the setting.
 
diff --git a/img2irc.py b/img2irc.py
@@ -14,11 +14,11 @@ pull request: https://github.com/ircart/scroll/pull/3
 import io
 
 try:
-	from PIL import Image, ImageEnhance, ImageOps
+	from PIL import Image, ImageEnhance, ImageFilter, ImageOps
 except ImportError:
 	raise SystemExit('missing required \'pillow\' library (https://pypi.org/project/pillow/)')
 
-effects  = ('greyscale', 'blackwhite', 'invert')
+effects  = ('blackwhite', 'blur', 'greyscale', 'invert', 'smooth')
 palettes = {
 	'RGB88': [0xffffff, 0x000000, 0x00007f, 0x009300, 0xff0000, 0x7f0000, 0x9c009c, 0xfc7f00,
 			  0xffff00, 0x00fc00, 0x009393, 0x00ffff, 0x0000fc, 0xff00ff, 0x0,      0x0,
@@ -59,12 +59,16 @@ def convert(data, max_line_len, img_width=80, palette='RGB99', brightness=False,
 		image = ImageEnhance.Brightness(im).enhance(brightness)
 	if contrast:
 		image = ImageEnhance.Contrast(image).enhance(contrast)
-	if effect == 'greyscale':
-		image = image.convert("L")
-	elif effect == 'blackwhite':
+	if effect == 'blackwhite':
 		image = image.convert("1")
+	elif effect == 'blur':
+		image - image.filter(ImageFilter.BLUR)
+	elif effect == 'greyscale':
+		image = image.convert("L")
 	elif effect == 'invert':
 		image = ImageOps.invert(image)
+	elif effect == 'smooth':
+		image = image.filter(ImageFilter.SMOOTH_MORE)
 	return convert_image(image, max_line_len, img_width, palette)
 
 def convert_image(image, max_line_len, img_width, palette):