mirror of
https://github.com/chubin/wttr.in
synced 2025-01-26 02:34:59 +00:00
Make background of png images configurable (#200)
This commit is contained in:
parent
33399b193b
commit
5ef9e3eddb
2 changed files with 7 additions and 2 deletions
|
@ -163,7 +163,7 @@ def _load_emojilib():
|
||||||
|
|
||||||
emojilib = {}
|
emojilib = {}
|
||||||
for filename in glob.glob("share/emoji/*.png"):
|
for filename in glob.glob("share/emoji/*.png"):
|
||||||
character = os.path.basename(filename)[:-4]
|
character = os.path.basename(filename)[:-3]
|
||||||
emojilib[character] = \
|
emojilib[character] = \
|
||||||
Image.open(filename).resize((CHAR_HEIGHT, CHAR_HEIGHT))
|
Image.open(filename).resize((CHAR_HEIGHT, CHAR_HEIGHT))
|
||||||
return emojilib
|
return emojilib
|
||||||
|
@ -183,7 +183,11 @@ def _gen_term(buf, graphemes, options=None):
|
||||||
cols = max(len(x) for x in buf)
|
cols = max(len(x) for x in buf)
|
||||||
rows = len(buf)
|
rows = len(buf)
|
||||||
|
|
||||||
image = Image.new('RGB', (cols * CHAR_WIDTH, rows * CHAR_HEIGHT))
|
bg_color = 0
|
||||||
|
if "background" in options:
|
||||||
|
bg_color = _color_mapping(options["background"])
|
||||||
|
|
||||||
|
image = Image.new('RGB', (cols * CHAR_WIDTH, rows * CHAR_HEIGHT), color=bg_color)
|
||||||
|
|
||||||
buf = buf[-ROWS:]
|
buf = buf[-ROWS:]
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ PNG options:
|
||||||
p # add frame around the output
|
p # add frame around the output
|
||||||
t # transparency 150
|
t # transparency 150
|
||||||
transparency=... # transparency from 0 to 255 (255 = not transparent)
|
transparency=... # transparency from 0 to 255 (255 = not transparent)
|
||||||
|
background=... # background color in form RRGGBB, e.g. 00aaaa
|
||||||
|
|
||||||
Options can be combined:
|
Options can be combined:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue