This commit is contained in:
jimmy 2022-07-21 18:58:27 +12:00
parent df590dbf19
commit a48c3ab596
1 changed files with 11 additions and 31 deletions

View File

@ -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)