-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_generate.py
61 lines (54 loc) · 2.31 KB
/
image_generate.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from PIL import Image, ImageDraw, ImageFont
def generate_wish_card_image(image,sender,receiver):
if (image == "onam_1"):
image=Image.open('static/cards/'+image+'.png')
font_size = 36
font = ImageFont.truetype('fonts/WindSong-Medium.ttf',font_size)
font_color =(82,44,20)
draw = ImageDraw.Draw(image)
position = (120,360)
draw.text(position,"Regards, "+sender,font=font,fill=font_color)
image.save(f"static/generated_cards/card_{sender.lower()}.png")
return True
elif (image == "onam_2"):
image=Image.open('static/cards/'+image+'.png')
font_size = 40
font = ImageFont.truetype('fonts/WindSong-Medium.ttf',font_size)
font_color =(164,69,3)
draw = ImageDraw.Draw(image)
position = (120,310)
draw.text(position,"Regards, "+sender,font=font,fill=font_color)
image.save(f"static/generated_cards/card_{sender.lower()}.png")
return True
elif (image == "onam_3"):
image=Image.open('static/cards/'+image+'.png')
font_size = 40
font = ImageFont.truetype('fonts/WindSong-Medium.ttf',font_size)
font_color =(251,186,77)
draw = ImageDraw.Draw(image)
position = (120,390)
draw.text(position,"Regards, "+sender,font=font,fill=font_color)
image.save(f"static/generated_cards/card_{sender.lower()}.png")
return True
elif (image == "onam_4"):
image=Image.open('static/cards/'+image+'.png')
font_size = 40
font = ImageFont.truetype('fonts/WindSong-Medium.ttf',font_size)
font_color =(255,255,255)
draw = ImageDraw.Draw(image)
position = (120,440)
draw.text(position,"Regards, "+sender,font=font,fill=font_color)
image.save(f"static/generated_cards/card_{sender.lower()}.png")
return True
elif (image == "onam_5"):
image=Image.open('static/cards/'+image+'.png')
font_size = 40
font = ImageFont.truetype('fonts/WindSong-Medium.ttf',font_size)
font_color =(252,128,1)
draw = ImageDraw.Draw(image)
position = (120,340)
draw.text(position,"Regards, "+sender,font=font,fill=font_color)
image.save(f"static/generated_cards/card_{sender.lower()}.png")
return True
else:
return False