From 0f9dc7a8866021485b46dc24319fed5aeafebbf9 Mon Sep 17 00:00:00 2001 From: jimmy Date: Thu, 21 Jul 2022 19:16:18 +1200 Subject: [PATCH] Select image based on number of lines --- printer/test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/printer/test.py b/printer/test.py index 150546e..4561cde 100644 --- a/printer/test.py +++ b/printer/test.py @@ -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")