mirror of
git://git.acid.vegas/scroll.git
synced 2024-11-24 17:16:39 +00:00
Added greyscale/blackwhite effects to img2irc (not implemented into scroll yet)
This commit is contained in:
parent
b0e8a15f0e
commit
22c2d78980
@ -45,13 +45,17 @@ palettes = {
|
|||||||
0xbcbcbc, 0xe2e2e2, 0xffffff]
|
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:
|
if palette not in palettes:
|
||||||
raise Exception('invalid palette option')
|
raise Exception('invalid palette option')
|
||||||
palette = palettes[palette]
|
palette = palettes[palette]
|
||||||
image = Image.open(io.BytesIO(data))
|
image = Image.open(io.BytesIO(data))
|
||||||
if enhance:
|
if enhance:
|
||||||
image = ImageEnhance.Contrast(image)
|
image = ImageEnhance.Contrast(image)
|
||||||
|
if effect == 'grey':
|
||||||
|
image = image.convert("L")
|
||||||
|
elif effect == 'black':
|
||||||
|
image = image.convert("1")
|
||||||
del data
|
del data
|
||||||
return convert_image(image, max_line_len, img_width, palette)
|
return convert_image(image, max_line_len, img_width, palette)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user