backend: convert input images to webp

This commit is contained in:
OleSTEEP 2025-10-02 23:09:00 +03:00
parent d786d7f7af
commit 4921d4bd6f
5 changed files with 32 additions and 7 deletions

View file

@ -4,6 +4,7 @@ from fastapi.middleware.cors import CORSMiddleware
from pathlib import Path
from vntypes import Novel, Mark
from utils import *
from db import VNDB
app = FastAPI()
@ -42,7 +43,4 @@ async def novel_thumb(thumb: Annotated[bytes, File()], filename: str):
@app.post("/api/screenshot")
async def screenshot(scrshot: Annotated[bytes, File()], filename: str):
Path("screens/").mkdir(exist_ok=True)
with open(Path("screens", filename), "wb") as file:
file.write(scrshot)
return {"file_size": len(scrshot)}
return {"file_size": save_image(scrshot, "screens", filename)}