Как удалить радиус обводки из текста, созданного с помощью Python Pillow?Python

Программы на Python
Anonymous
Как удалить радиус обводки из текста, созданного с помощью Python Pillow?

Сообщение Anonymous »

Мне нужна обводка вокруг текста, но когда я использую встроенные параметры текстовой функции, граница имеет закругленные края. Вместо этого я хочу, чтобы граница имела острые углы.
Я хочу, чтобы края были острыми, как на прикрепленном изображении:
Изображение

font = ImageFont.truetype(font_family_path, font_size)
temp_image = Image.new('RGBA', (1, 1), (0, 0, 0, 0))

(https://i.sstatic.net/mLETp0ZD.png)
[In the above attached image link, you can see that currently, I have a stroke with rounded corners, but I want the border to have sharp edges.,]

draw = ImageDraw.Draw(temp_image)
bbox = draw.textbbox((0, 0), name, font=font)
text_width = bbox[2] - bbox[0]
text_height = bbox[3] - bbox[1]
image = Image.new('RGBA', (width, height), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
text_x = (width - text_width) / 2
text_y = (height - text_height) / 2 - (bbox[1] - 0)

draw.text((text_x, text_y), name, font=font, fill=(r, g, b),stroke_width=outline_width, stroke_fill=(stroke_r ,stroke_g, stroke_b))



Подробнее здесь: https://stackoverflow.com/questions/787 ... hon-pillow

Вернуться в «Python»