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)