Combine
This commit is contained in:
parent
b4bd9756fb
commit
d53cbb4eb3
16
server.py
16
server.py
|
@ -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}"}
|
Loading…
Reference in New Issue