This commit is contained in:
jimmy 2022-11-05 00:56:36 +13:00
parent b4bd9756fb
commit d53cbb4eb3
1 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,6 @@
from fastapi import FastAPI, File, UploadFile
from printer import printer
import StarTSPImage
from PIL import Image
app = FastAPI()
@ -14,6 +15,17 @@ def upload(file: UploadFile = File(...)):
finally:
file.file.close()
printer()
fr=Image.open("frame.png")
im=Image.open("image.png")
im = im.resize((432, 432), Image.Resampling.BOX)
fr.paste(im, (34,34), im)
#fr.show()
raster = StarTSPImage.imageToRaster(fr, cut=True)
printer = open('/dev/usb/lp0', "wb")
printer.write(raster)
return {"message": f"Successfully uploaded {file.filename}"}