From 7dd42abe8d6b6051e285e32f47bf4473f70d1611 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Fri, 3 Apr 2020 20:27:00 +0200 Subject: [PATCH] added lib/extract_emoji.py --- lib/extract_emoji.py | 62 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 lib/extract_emoji.py diff --git a/lib/extract_emoji.py b/lib/extract_emoji.py new file mode 100644 index 0000000..8c42675 --- /dev/null +++ b/lib/extract_emoji.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +#vim: fileencoding=utf-8 + +""" + +At the moment, Pillow library does not support colorful emojis, +that is why emojis must be extracted to external files first, +and then they must be handled as usual graphical objects +and not as text. + +The files are extracted using Imagemagick. + +Usage: + + ve/bi/python lib/extract_emoji.py +""" + +import subprocess + +EMOJIS = [ + "✨", + "☁️", + "🌫", + "🌧", + "🌧", + "❄️", + "❄️", + "🌦", + "🌦", + "🌧", + "🌧", + "🌨", + "🌨", + "⛅️", + "☀️", + "🌩", + "⛈", + "⛈", + "☁️", + "🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘" +] + +def extract_emojis_to_directory(dirname): + """ + Extract emoji from an emoji font, to separate files. + """ + + emoji_font = "Noto Color Emoji" + emoji_size = 30 + + for emoji in EMOJIS: + filename = "%s/%s.png" % (dirname, emoji) + convert_string = [ + "convert", "-background", "black", "-size", "%sx%s" % (emoji_size, emoji_size), + "-set", "colorspace", "sRGB", + "pango:%s" % (emoji_font, emoji), + filename + ] + subprocess.Popen(convert_string) + +if __name__ == '__main__': + extract_emojis_to_directory("share/emoji")