简体   繁体   English

如何在 Google Colab 中安装“libraqm”库?

[英]How do I install 'libraqm' library in Google Colab?

I want to install libraqm library in Google colab.我想在 Google colab 中安装libraqm库。 I've got a lot of images to work with and to add emoji text on those I need this particular library.我有很多图像可以使用,并在我需要这个特定库的那些图像上添加表情符号文本。 I also tried putting pre-built .dlls in the directories but nothing works.我还尝试将预先构建的 .dll 放在目录中,但没有任何效果。 Any answer will be helpful.任何答案都会有所帮助。

Also, installing libraqm this way and running the code crashes it.此外, libraqm这种方式安装libraqm并运行代码libraqm它崩溃。

!sudo apt install libraqm-dev

example of the code I'm trying to run:我试图运行的代码示例:

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), "a\u263A", fill="#faa2", embedded_color=True, font=fnt)
    draw.text((0, 132), "a\u263A", fill="#faa8", embedded_color=True, font=fnt)
    draw.text((0, 232), "a\u263A", fill="#faa", embedded_color=True, font=fnt)
    draw.text((0, 332), "\U0001F3AC\U0001F44B\U0001F3FB\U0001F44B\U0001F3FF", fill="white", embedded_color=True, font=fnt)
    draw.text((0, 432), "a\u263A", fill="#faa2", font=fnt)
    im.show()
    im.save(f"testemoji_{out_name}.png")

test(r"C:\Users\Nulano\Downloads\NotoColorEmoji.ttf", "cbdt")
test("seguiemj.ttf", "colr")

Just fixed this for myself !刚刚为自己修好了这个!

try this:试试这个:

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

if you get "True", its gonna work !如果你得到“真”,它会起作用!

  • you had to rebuild Pillow to work with libraqm, make sure you restart your notebook !您必须重建 Pillow 才能使用 libraqm,请确保重新启动笔记本!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM