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)