Files
portfolio/tools/artwork.py
T

30 lines
1.4 KiB
Python

"""Optional Pillow helper to render original social-sharing artwork.
The generated PNG is checked in; a normal portfolio build needs no Pillow.
"""
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
import os
ROOT=Path(__file__).resolve().parents[1]
image=Image.new('RGB',(1200,630),'#0b141b')
draw=ImageDraw.Draw(image)
font_folder=Path(os.environ.get('WINDIR','C:/Windows'))/'Fonts'
def font(size,bold=False):
name='segoeuib.ttf' if bold else 'segoeui.ttf'
path=font_folder/name
if path.is_file(): return ImageFont.truetype(str(path),size)
return ImageFont.load_default(size=size)
draw.rounded_rectangle((58,54,130,126),radius=36,outline='#9ae4f0',width=2)
draw.text((74,76),'NQ',font=font(24),fill='#9ae4f0')
draw.text((153,64),'NICHOLAS QUANDT',font=font(22,True),fill='#edf4f8')
draw.text((153,95),'Software & systems engineering',font=font(17),fill='#a2b1bc')
draw.text((60,175),'Desktop software.',font=font(64,True),fill='#edf4f8')
draw.text((60,252),'Connected devices.',font=font(64,True),fill='#edf4f8')
draw.text((60,329),'Resilient systems.',font=font(64,True),fill='#9ae4f0')
draw.line((60,454,1140,454),fill='#2b3b46',width=2)
draw.text((60,485),'Centra Tab / Repo Relay / Remoraid / NfcAuth',font=font(24),fill='#a2b1bc')
draw.text((60,550),'code.knickqueue.win',font=font(20),fill='#9ae4f0')
image.save(ROOT/'assets/images/social.png',optimize=True)
print('Rendered original 1200x630 sharing artwork.')