from PIL import Image, ImageDraw, ImageFont

size = (1200, 628)
width, height = size

title_text = "On Disaster Recovery"
description_text = "Stupid shutdowns and lucky lockouts"
ibm_plex_mono = ImageFont.truetype("IBMPlexMono-Bold.ttf", 62)
inter = ImageFont.truetype("InterVariable.ttf", 28)

img = Image.new("RGB", size, "#e7e7e7")
d = ImageDraw.Draw(img)

d.rectangle(((0, 0), (1200, 20)), fill="#df3062")

# Place title
bbox = ibm_plex_mono.getbbox(title_text)
bbox_width = bbox[2] - bbox[0]
bbox_height = bbox[3] - bbox[1]
title_pos = ((width / 2) - (bbox_width / 2), ((height / 2) - 125) - (bbox_height / 2))
d.text(title_pos, title_text, font=ibm_plex_mono, fill="#000000", align="center")

print(bbox, bbox_height)

# Place description
t_bbox_height = bbox_height
bbox = inter.getbbox(description_text)
bbox_width = bbox[2] - bbox[0]
bbox_height = bbox[3] - bbox[1]
desc_pos = ((width / 2) - (bbox_width / 2), title_pos[1] + (t_bbox_height*(title_text.count("\n") + 1)) + 25)
d.text(desc_pos, description_text, font=inter, fill="#000000", align="center")

# Place logo
logo = Image.open("abiabi.png")
img.paste(logo, (50, 50))

img.save("metaimg-test.png")