What happens when you don't have a pen

This commit is contained in:
jimmy 2022-09-21 00:51:44 +12:00
parent 653257b787
commit c996650414
1 changed files with 28 additions and 0 deletions

28
printer/press.py Normal file
View File

@ -0,0 +1,28 @@
import StarTSPImage
from PIL import Image, ImageDraw, ImageFont, ImageOps
import textwrap
import random
im = Image.new('RGB', (500, 1600), color = 'white')
# f = ImageFont.load_default()
f = ImageFont.truetype("printer/SilkRemington-Regular.otf", 100)
txt=Image.new('L', (1600,500))
d = ImageDraw.Draw(txt)
d.text((50, 50), "(When flashing)", font=f, fill=255)
w=txt.rotate(-90, expand=1)
im.paste( ImageOps.colorize(w, (0,0,0), (0,0,0)), (-100, 60), w)
im.show()
# im.save("image_tmp.jpg")
raster = StarTSPImage.imageToRaster(im, cut=True)
printer = open('/dev/usb/lp0', "wb")
printer.write(raster)