-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrawPhotoExample.py
41 lines (32 loc) · 1.08 KB
/
DrawPhotoExample.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
from unittest import result
from PIL import Image, ImageDraw, ImageFont
from RoyaleKeys import keys
# Size text where is most viewest
def sizeTextCenter(W, H):
if W > H:
return W
else:
return 10
def centerText(W, H):
if W > H:
return (int(H/2), int(-W/2))
else:
return (int(0), int(-W/2))
def copiaFoto():
locationImage = keys["path"]["img_asesino"]
msg = keys["eliminated_image"]["text"]
mfontText = keys["eliminated_image"]["font"]
mColor = keys["eliminated_image"]["color"]
locationImage = keys["path"]["img_asesino"]
msg = keys["eliminated_image"]["text"]
mfontText = keys["eliminated_image"]["font"]
mColor = keys["eliminated_image"]["color"]
im = Image.open(locationImage).convert('RGBA')
W, H = im.size
draw = ImageDraw.Draw(im)
w, h = draw.textsize(msg)
mfont = ImageFont.truetype(mfontText, sizeTextCenter(W, H))
draw.text(centerText(W, H), msg, fill=mColor, font=mfont)
im.save(keys["path"]["img_victima"], "PNG")
print("W:{} H:{} w:{} h:{}".format(W, H, w, h))
copiaFoto()