save code
This commit is contained in:
@@ -18,6 +18,7 @@ from pathlib import Path
|
||||
|
||||
import httpx
|
||||
import oss2
|
||||
from PIL import Image
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import FileResponse
|
||||
@@ -201,6 +202,15 @@ async def try_on(req: TryOnRequest):
|
||||
async with httpx.AsyncClient(timeout=30.0) as dl_client:
|
||||
result_bytes = await fetch_image_bytes(dl_client, filename, subfolder, type_)
|
||||
|
||||
# 缩放到 768x1024
|
||||
# img = Image.open(io.BytesIO(result_bytes))
|
||||
# img = img.resize((768, 1024), Image.LANCZOS)
|
||||
# buf = io.BytesIO()
|
||||
# fmt = (Path(filename).suffix.lstrip(".") or "png").upper()
|
||||
# fmt = "JPEG" if fmt in ("JPG", "JPEG") else fmt
|
||||
# img.save(buf, format=fmt)
|
||||
# result_bytes = buf.getvalue()
|
||||
|
||||
# 将图片保存到临时文件,上传到 OSS
|
||||
suffix = Path(filename).suffix or ".png"
|
||||
object_name = f"tryon/{uuid.uuid4().hex}{suffix}"
|
||||
|
||||
Reference in New Issue
Block a user