esp_time/images/create_digits.py

26 lines
873 B
Python
Raw Normal View History

#!/usr/bin/env python
from PIL import Image, ImageDraw, ImageFont
fnt = ImageFont.truetype('/Library/Fonts/FreeMono.ttf', 336)
2019-11-26 23:42:01 +11:00
sfnt= ImageFont.truetype('/Library/Fonts/FreeMono.ttf', 168)
2019-11-26 23:42:01 +11:00
# Large numerals
for I in ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"):
img = Image.new('RGB', (185, 224), color = (255, 255, 255))
d = ImageDraw.Draw(img)
d.text((0,-60), I, font=fnt, fill=(0,0,0))
img.save("%s.jpg" % (I))
2019-11-26 23:42:01 +11:00
imgs = Image.new("RGB", (92, 112), color = (255, 255, 255))
d = ImageDraw.Draw(imgs)
d.text((0,-30), I, font=sfnt, fill=(0,0,0))
imgs.save(I+"s.jpg")
img = Image.new('RGB', (60,224), color = (255, 255, 255))
d = ImageDraw.Draw(img)
d.text((-70,-60), ":", font=fnt, fill=(0,0,0))
# the -70 offset gets the : in the right spot for a 60 pixel wide image. Could proabably reduce the font size a bit
img.save("COLO.jpg");