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