png - 以编程方式获取 unicode 表情符号的 PNG

标签 png emoji python-unicode

在Python中,我有一个像这样的组合表情符号:“👨”+“\u200D”+“🔧”,通常表示为https://emojipedia.org/male-mechanic/ 。我想要一个 PNG 版本用作绘图点(在 matplotlib 中,如果有帮助的话)。有没有任何官方或非官方的地方可以将 unicode 版本的表情符号转换为 PNG 等效版本?

最佳答案

对于其他正在寻找答案的人,目前我正在使用 https://unicode.org/emoji/charts/full-emoji-list.html 中的 PNG。 ,使用解析网页的 hack,如下所示

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

关于png - 以编程方式获取 unicode 表情符号的 PNG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53721028/

相关文章:

encoding - 使用 ffmpeg 将 png 帧无损编码为 webm

image - 如何使用 GIF 获得更好的透明度?

python - Python中使用unicode字符时的不同编码

python - python re (regex) 是否有 unicode 转义序列的替代方案?

python - Python2 的子进程/命令模块是否支持 Unicode?

delphi - PNGImage "Access violation"程序结束时出现错误

css - 将彩色图像png转换为彩色css渐变

python - 从 Python 中的字符串中删除表情符号

ios - 使用扩展/UIgraphicscontext 将表情符号(字符串)呈现为 iOS 中可能的最高分辨率图像

excel - 请参阅使用图标/表情符号作为名称一部分的工作表