C
C
CatRoys2020-06-13 01:55:35
Python
CatRoys, 2020-06-13 01:55:35

How to make "text area" on an image in PIL library?

There was such a problem that the text goes beyond the picture. What method can fix this? Here is my script:

img = Image.open("123.jpg")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("1234.ttf", size=32)
draw.text((80, 80), "о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-о-очень длинный текст", font=font)
img.save('12345.jpg')

Here's what it looks like:
5ee407d7a45d7185101308.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-06-13
@CatRoys

Python, PIL, text wrapping

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question