Dynamic Text
This commit is contained in:
parent
7059a572b3
commit
a99fd4a928
1 changed files with 53 additions and 10 deletions
63
imageGen.py
63
imageGen.py
|
|
@ -1,7 +1,7 @@
|
|||
from openpyxl import Workbook
|
||||
import cords
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
import numpy as np
|
||||
|
||||
def gen_I_Mountain(wb):
|
||||
## I Mountain image code
|
||||
|
|
@ -25,12 +25,36 @@ def gen_I_Mountain(wb):
|
|||
graph_comp = Image.composite(blank, I_Mountain, I_Mountain_Mask) #.save("./gen/I_mountain.png")
|
||||
draw = ImageDraw.Draw(graph_comp)
|
||||
font = ImageFont.truetype("./fonts/Asap_Condensed/AsapCondensed-Bold.ttf", 36)
|
||||
draw.text((442, 623),"12K",(0,0,0),font=font)
|
||||
draw.text((442, 623),format_frendly(wb["I Mountain"]["A2"].value),(0,0,0),font=font)
|
||||
|
||||
#Add box values
|
||||
|
||||
if wb["I Mountain"]["B16"].value:
|
||||
icon = Image.open('./templets/icons/checkmark-svgrepo-com.png')
|
||||
icon = cords.scale(icon,0.035)
|
||||
graph_comp.paste(icon, cords.center_on(icon, (1125,365)),icon)
|
||||
else:
|
||||
icon = Image.open('./templets/icons/checkmark-svgrepo-com.png')
|
||||
icon = cords.scale(icon,0.035)
|
||||
graph_comp.paste(icon, cords.center_on(icon, (1237,365)),icon)
|
||||
|
||||
if wb["I Mountain"]["B17"].value:
|
||||
icon = Image.open('./templets/icons/checkmark-svgrepo-com.png')
|
||||
icon = cords.scale(icon,0.035)
|
||||
graph_comp.paste(icon, cords.center_on(icon, (910,910)),icon)
|
||||
else:
|
||||
icon = Image.open('./templets/icons/checkmark-svgrepo-com.png')
|
||||
icon = cords.scale(icon,0.035)
|
||||
graph_comp.paste(icon, cords.center_on(icon, (1035,910)),icon)
|
||||
|
||||
graph_comp.save("./gen/I_mountain.png")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def gen_O_Mountain(wb):
|
||||
## O Mountain Image Code
|
||||
O_Mountain = Image.open('./templets/O_mountain.png').convert('RGBA').resize((1920, 1080))
|
||||
|
|
@ -40,21 +64,21 @@ def gen_O_Mountain(wb):
|
|||
blank = Image.open('./templets/O_mountain.png').convert('RGBA').resize((1920, 1080))
|
||||
blank2 = Image.new('RGBA',(1920,1080))
|
||||
|
||||
K401 = Image.open('./.gen/401K_Contribution.png')
|
||||
K401 = Image.open('./.gen/401K_Catch_Up.png')
|
||||
K401 = cords.scale(K401,0.378)
|
||||
blank.paste(K401, cords.center_on(K401,(386,806)),K401)
|
||||
blank.paste(K401, cords.center_on(K401,(549,806)),K401)
|
||||
|
||||
K401C = Image.open('./.gen/401K_Catch_Up.png')
|
||||
K401C = Image.open('./.gen/401K_Contribution.png')
|
||||
K401C = cords.scale(K401C,0.378)
|
||||
blank2.paste(K401C, cords.center_on(K401C,(557,806)),K401C)
|
||||
blank2.paste(K401C, cords.center_on(K401C,(384,806)),K401C)
|
||||
|
||||
IRAC = Image.open('./.gen/Roth_Catch_Up.png')
|
||||
IRAC = cords.scale(IRAC,0.265)
|
||||
blank.paste(IRAC, cords.center_on(IRAC,(1177,855)),IRAC)
|
||||
blank.paste(IRAC, cords.center_on(IRAC,(1172,855)),IRAC)
|
||||
|
||||
IRA = Image.open('./.gen/Roth_IRA.png')
|
||||
IRA = cords.scale(IRA,0.265)
|
||||
blank2.paste(IRA, cords.center_on(IRA,(1425,855)),IRA)
|
||||
blank2.paste(IRA, cords.center_on(IRA,(1421,855)),IRA)
|
||||
|
||||
|
||||
if wb["O Mountain"]["B16"].value:
|
||||
|
|
@ -68,11 +92,24 @@ def gen_O_Mountain(wb):
|
|||
|
||||
|
||||
|
||||
|
||||
#Mask and combine
|
||||
blank2 = Image.composite(blank2, Image.new('RGBA',(1920,1080)), O_Mountain_Mask2)
|
||||
blank = Image.alpha_composite(blank,blank2)
|
||||
|
||||
#Mask and combine
|
||||
Image.composite(blank, O_Mountain, O_Mountain_Mask).save("./gen/O_mountian.png")
|
||||
|
||||
graph_comp = Image.composite(blank, O_Mountain, O_Mountain_Mask)
|
||||
draw = ImageDraw.Draw(graph_comp)
|
||||
font = ImageFont.truetype("./fonts/Asap_Condensed/AsapCondensed-Bold.ttf", 36)
|
||||
|
||||
draw.text((440, 595),format_frendly(wb["O Mountain"]["B6"].value),(0,0,0),font=font)
|
||||
draw.text((605, 595),format_frendly(wb["O Mountain"]["B8"].value),(0,0,0),font=font)
|
||||
|
||||
draw.text((1485, 703),format_frendly(wb["O Mountain"]["B2"].value),(0,0,0),font=font)
|
||||
draw.text((1240, 703),format_frendly(wb["O Mountain"]["B4"].value),(0,0,0),font=font)
|
||||
|
||||
graph_comp.save("./gen/O_mountian.png")
|
||||
|
||||
|
||||
|
||||
def gen_Oh_I_Mountain(wb):
|
||||
|
|
@ -87,3 +124,9 @@ def gen_Oh_I_Mountain(wb):
|
|||
|
||||
#Mask and combine
|
||||
Image.composite(blank, Oh_I_Mountain, Oh_I_Mountain_Mask).save("./gen/Oh_I_mountain.png")
|
||||
|
||||
|
||||
|
||||
def format_frendly(num):
|
||||
T = num / 1000
|
||||
return str(int(np.floor(T)))+"K"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue