From a48c3ab5963e5ca5bfefac9ae27cf4a5b8de7311 Mon Sep 17 00:00:00 2001 From: jimmy Date: Thu, 21 Jul 2022 18:58:27 +1200 Subject: [PATCH] Tweak --- printer/test.py | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/printer/test.py b/printer/test.py index b5b7abf..150546e 100644 --- a/printer/test.py +++ b/printer/test.py @@ -2,40 +2,20 @@ import StarTSPImage from PIL import Image, ImageDraw, ImageFont, ImageOps import textwrap +# with open("printer/locations.txt") as locations: +# pass -# #image = Image.new('RGB', (2000, 2000), color='White') -# image = Image.open("printer/image.jpg") +# with open("printer/actions.txt") as actions: +# pass - -# txt=Image.new('L', (1000,500)) -# font = ImageFont.truetype("printer/font.ttf", 30) -# draw = ImageDraw.Draw(txt) - - -# draw.text((0, 0),"Sample Text",font=font) -# w=txt.rotate(90, expand=1) - -# image.paste( ImageOps.colorize(w, (0,0,0), (0,0,0)), (0,0), w) -# image.show() - - -# im=Image.open("image.jpg") - -# f = ImageFont.load_default() -# txt=Image.new('L', (500,50)) -# d = ImageDraw.Draw(txt) -# d.text( (0, 0), "Someplace Near Boulder", font=f, fill=255) -# w=txt.rotate(17.5, expand=1) - -# im.paste( ImageOps.colorize(w, (0,0,0), (255,255,84)), (242,60), w) - -# im.show +# with open("printer/adverb.txt") as adverb: +# pass im=Image.open("printer/image.jpg") # f = ImageFont.load_default() -f = ImageFont.truetype("printer/Jua-Regular.ttf", 45) -txt=Image.new('L', (1000,225)) +f = ImageFont.truetype("printer/SilkRemington-Regular.otf", 40) +txt=Image.new('L', (1000,230)) d = ImageDraw.Draw(txt) text_short = "By the DJ, offer a stranger a drink" @@ -52,12 +32,12 @@ 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 + 130, 5), w) +im.paste( ImageOps.colorize(w, (0,0,0), (0,0,0)), ( (n-5)*20 + 123, 5), w) im.show() -#image.save("image_tmp.jpg") +im.save("image_tmp.jpg") raster = StarTSPImage.imageToRaster(im, cut=True) printer = open('/dev/usb/lp0', "wb") -printer.write(raster) +#printer.write(raster)