-
Notifications
You must be signed in to change notification settings - Fork 0
/
v1.py
35 lines (29 loc) · 1.06 KB
/
v1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import textwrap
from PIL import Image, ImageDraw, ImageFont
if __name__ == "__main__":
import textwrap
python_desc = """Explore the latest innovations and advancements in the field of green and sustainable energy."""
my_wrap = textwrap.TextWrapper(
width=25,
tabsize=4,
max_lines=3,
placeholder='...',
)
wrap_list = my_wrap.fill(text=python_desc)
# create an image
image_width, image_height = 1200, 630
background_color = 6, 8, 103, 1
img = Image.new("RGB", (image_width, image_height), color=background_color)
# Choose a font and size
font_path = 'assets/fonts/otf/IkiMono-Regular.otf'
font_size = 60
font_color = "white"
font = ImageFont.truetype(font_path, font_size)
# get a drawing context
draw = ImageDraw.Draw(img)
# Add text as a logo at the top left corner
logo_text = "LOGO"
draw.text((130, 60), logo_text, font=font, fill=font_color)
# draw multiline text
draw.multiline_text((130, 250), wrap_list, font=font, fill=font_color, spacing=15)
img.show()