rogerxavier
commited on
Commit
•
679ffd8
1
Parent(s):
da78506
Update api.py
Browse files
api.py
CHANGED
@@ -32,14 +32,16 @@ def t5():
|
|
32 |
|
33 |
|
34 |
##这个比较快不用异步
|
35 |
-
@app.post("/getOriginalMangaList")
|
36 |
-
|
|
|
37 |
for idx, image in enumerate(images):
|
38 |
-
img =
|
39 |
-
|
40 |
-
path_to_image = f"
|
41 |
-
|
42 |
-
|
|
|
43 |
##这个比较快不用异步
|
44 |
|
45 |
##这个比较快不用异步
|
|
|
32 |
|
33 |
|
34 |
##这个比较快不用异步
|
35 |
+
@app.post("/getOriginalMangaList") #增加指定保存路径功能,默认是/manga路径
|
36 |
+
def getOriginalMangaList(images: List[UploadFile] = File(...), save_path: str = "/manga"):
|
37 |
+
saved_files = []
|
38 |
for idx, image in enumerate(images):
|
39 |
+
img = image.file.read()
|
40 |
+
image_data = Image.open(io.BytesIO(img)).convert("L").convert("RGB")
|
41 |
+
path_to_image = os.path.join(save_path, f"{idx}.jpg")
|
42 |
+
image_data.save(path_to_image)
|
43 |
+
saved_files.append(path_to_image)
|
44 |
+
return {"message": "Images saved successfully", "saved_files": saved_files}
|
45 |
##这个比较快不用异步
|
46 |
|
47 |
##这个比较快不用异步
|