kac/printer.py

25 lines
509 B
Python
Raw Normal View History

2022-11-04 01:51:04 +00:00
import StarTSPImage
from PIL import Image, ImageDraw, ImageFont, ImageOps
import textwrap
import random
2022-11-04 09:22:56 +00:00
def printer(path):
#432x432
#34 34
2022-11-04 01:51:04 +00:00
2022-11-04 09:22:56 +00:00
432/48
fr=Image.open("frame.png")
im=Image.open(path)
im = im.resize((432, 432), Image.Resampling.BOX)
2022-11-04 01:51:04 +00:00
2022-11-04 09:22:56 +00:00
fr.paste(im, (34,34), im)
fr.show()
raster = StarTSPImage.imageToRaster(fr, cut=True)
2022-11-04 01:51:04 +00:00
printer = open('/dev/usb/lp0', "wb")
printer.write(raster)
if __name__ == "__main__":
2022-11-04 09:22:56 +00:00
printer("./images/test.png")