Home Articles Books Search About
日本語
Handling AttributeError: 'ImageDraw' object has no attribute 'textsize'

Handling AttributeError: 'ImageDraw' object has no attribute 'textsize'

When using the following in Python’s Pillow: textsize = 14 font = ImageFont.truetype("Arial Unicode.ttf", size=textsize) txw, txh = draw.textlength(label, font=font) The following error occurred. AttributeError: ‘ImageDraw’ object has no attribute ’textsize’ The following was helpful as a solution. https://stackoverflow.com/questions/77038132/python-pillow-pil-doesnt-recognize-the-attribute-textsize-of-the-object-imag Specifically, I rewrote it as follows. textsize = 14 font = ImageFont.truetype("Arial Unicode.ttf", size=textsize) txw = draw.textlength(label, font=font) txh = textsize I hope this is helpful.