Dynamically generate

This commit is contained in:
jimmy 2022-07-21 19:48:30 +12:00
parent 573f300fea
commit 1bcb39820c
1 changed files with 12 additions and 7 deletions

View File

@ -1,15 +1,19 @@
import StarTSPImage
from PIL import Image, ImageDraw, ImageFont, ImageOps
import textwrap
import random
# with open("printer/locations.txt") as locations:
# pass
with open("printer/locations.txt") as locations:
lines = locations.read().splitlines()
location = random.choice(lines)
# with open("printer/actions.txt") as actions:
# pass
with open("printer/actions.txt") as actions:
lines = actions.read().splitlines()
action = random.choice(lines)
# with open("printer/adverb.txt") as adverb:
# pass
with open("printer/adverbs.txt") as adverb:
lines = adverb.read().splitlines()
adverb = random.choice(lines)
im=Image.open("printer/image2.jpg")
@ -18,10 +22,11 @@ f = ImageFont.truetype("printer/SilkRemington-Regular.otf", 40)
txt=Image.new('L', (1000,230))
d = ImageDraw.Draw(txt)
text = "While {}, {}, {}".format(location, action, adverb)
text_short = "By the DJ, offer a stranger a drink"
text_long = "In the outdoor area, ask someone would you rather be known for always being honest or always being kind"
lines = textwrap.wrap(text_long, width=23)
lines = textwrap.wrap(text, width=23)
if len(lines) > 2:
im=Image.open("printer/image.jpg")