本文介绍了如何在Google Colab中安装libraqm;库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Google CoLab中安装libraqm库。我有很多图片要处理,并且要在这些图片上添加表情文字,我需要这个特定库。我还尝试将预先构建的.dlls放入目录中,但都不起作用。任何答案都会有帮助。

另外,以这种方式安装libraqm并运行代码会使其崩溃。

!sudo apt install libraqm-dev

我尝试运行的代码示例:

from PIL import Image, ImageDraw, ImageFont

def test(font, out_name):
    fnt = ImageFont.truetype(font, size=109, layout_engine=ImageFont.LAYOUT_RAQM)
    im = Image.new("RGBA", (600, 600), (100, 100, 100, 100))
    draw = ImageDraw.Draw(im)
    draw.text((0, 32), "au263A", fill="#faa2", embedded_color=True, font=fnt)
    draw.text((0, 132), "au263A", fill="#faa8", embedded_color=True, font=fnt)
    draw.text((0, 232), "au263A", fill="#faa", embedded_color=True, font=fnt)
    draw.text((0, 332), "U0001F3ACU0001F44BU0001F3FBU0001F44BU0001F3FF", fill="white", embedded_color=True, font=fnt)
    draw.text((0, 432), "au263A", fill="#faa2", font=fnt)
    im.show()
    im.save(f"testemoji_{out_name}.png")

test(r"C:UsersNulanoDownloadsNotoColorEmoji.ttf", "cbdt")
test("seguiemj.ttf", "colr")

推荐答案

刚刚为我自己解决了这个问题!

试试这个:

!sudo apt install libraqm-dev
!pip3 install -v --upgrade --force-reinstall Pillow
from PIL import features
print(features.check('raqm'))

如果您获得&Quot;True&Quot;,它将起作用!

  • 您必须重建枕头才能使用libraqm,请确保重新启动笔记本!

这篇关于如何在Google Colab中安装libraqm;库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-18 22:02