Reputation: 2109
In python I have a combined emoji like this: "👨" + "\u200D" + "🔧"
which is normally represented as https://emojipedia.org/male-mechanic/. I want to get a PNG version to use as a plot point (in matplotlib, if that helps). Is there any official or unofficial place where I can convert unicode versions of emojis into PNG equivalents?
Upvotes: 2
Views: 2902
Reputation: 2109
For anyone else looking for an answer, at the moment I'm using the PNGs from https://unicode.org/emoji/charts/full-emoji-list.html, with a hack that parses the web page, like this
class EmojiConverter:
def __init__(self):
import requests
import re
self.data = requests.get('https://unicode.org/emoji/charts/full-emoji-list.html').text
def to_base64_png(self, emoji, version=0):
"""For different versions, you can set version = 0 for , """
html_search_string = r"<img alt='{}' class='imga' src='data:image/png;base64,([^']+)'>" #'
matchlist = re.findall(html_search_string.format(emoji), self.data)
return matchlist[version]
e = EmojiConverter()
b64 = e.to_base64_png("👨"+"\u200D" + "🔧")
Upvotes: 4