1
mirror of git://git.acid.vegas/scroll.git synced 2024-11-07 08:46:45 +00:00

Added greyscale/blackwhite effects to img2irc (not implemented into scroll yet)

This commit is contained in:
Dionysus 2023-06-28 15:12:45 -04:00
parent b0e8a15f0e
commit 22c2d78980
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE

View File

@ -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)