import StarTSPImage from PIL import Image, ImageDraw, ImageFont, ImageOps import textwrap import random def printer(): im = Image.new("RGB", (800, 1280), (0, 0, 0)) # im.show() raster = StarTSPImage.imageToRaster(im, cut=True) printer = open('/dev/usb/lp0', "wb") printer.write(raster) if __name__ == "__main__": printer()