PythonのPillowを使って画像に縦書きの日本語文字を入れる方法

方法

pip install Pillow
from PIL import Image, ImageDraw, ImageFont

text = 'この?'
font_size = 72
font = ImageFont.truetype('./GN-KillGothic-U-KanaO.ttf', font_size)
img = Image.open('dwpose.png')
draw = ImageDraw.Draw(img)
draw.text((10, 50), text, 'red', font=font, direction='ttb')
img.save('text.jpg')

#KeyError: 'setting text direction, language or font features is not supported without libraqm'
#ImageDraw.text(xy, text, fill=None, font=None, anchor=None, spacing=4, align='left', direction=None, features=None, language=None, stroke_width=0, stroke_fill=None, embedded_color=False, font_size=None)

ImageDraw Module – Pillow (PIL Fork) 10.2.0 documentation

KeyError: 'setting text direction, language or font features is not supported without libraqm’

Python

Posted by eightban