eightban's memo

残しておきたい記事をまとめてみました。このブログに書いてあるドキュメントやブログで配布しているファイルの使用によって発生するいかなる損害に対してもこのブログの管理者は責任を負いません。使用する場合は自己責任のもとに使用してください。

Python

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

Copyright© eightban's memo , 2024 All Rights Reserved Powered by STINGER.