Select image based on number of lines

This commit is contained in:
jimmy 2022-07-21 19:16:18 +12:00
parent a48c3ab596
commit 0f9dc7a886
1 changed files with 7 additions and 2 deletions

View File

@ -11,7 +11,7 @@ import textwrap
# with open("printer/adverb.txt") as adverb:
# pass
im=Image.open("printer/image.jpg")
im=Image.open("printer/image2.jpg")
# f = ImageFont.load_default()
f = ImageFont.truetype("printer/SilkRemington-Regular.otf", 40)
@ -23,6 +23,11 @@ text_long = "In the outdoor area, ask someone would you rather be known for alwa
lines = textwrap.wrap(text_long, width=23)
if len(lines) > 2:
im=Image.open("printer/image.jpg")
else:
im=Image.open("printer/image2.jpg")
y = 0
n = 0
for line in lines:
@ -32,7 +37,7 @@ for line in lines:
y += height
w=txt.rotate(-90, expand=1)
print(n)
im.paste( ImageOps.colorize(w, (0,0,0), (0,0,0)), ( (n-5)*20 + 123, 5), w)
im.paste( ImageOps.colorize(w, (0,0,0), (0,0,0)), ( (n-5)*20 + 127, 5), w)
im.show()
im.save("image_tmp.jpg")