PythonのPillowで以下を使用していた際、
textsize = 14
font = ImageFont.truetype("Arial Unicode.ttf", size=textsize)
txw, txh = draw.textlength(label, font=font)
以下のエラーが発生しました。
AttributeError: 'ImageDraw' object has no attribute 'textsize'
この対処法として、以下が参考になりました。
Python pillow/PIL doesn't recognize the attribute "textsize" of the object "imagedraw"
I already checked python version on my environment (sublime text) and it is 3.11.0, the latest, I checked pillow version which is 10.0.0, the latest, and my code looks similar to other examples onl...
具体的には、以下のように書き直しました。
textsize = 14
font = ImageFont.truetype("Arial Unicode.ttf", size=textsize)
txw = draw.textlength(label, font=font)
txh = textsize
参考になりましたら幸いです。
動画版(生成AIによる自動生成): この記事の内容をずんだもん×四国めたんの掛け合いで解説しています。自動生成のため、内容に誤りがある可能性があります。正確な情報は記事本文をご参照ください。




コメント
…