86 lines
2.7 KiB
Python
86 lines
2.7 KiB
Python
|
# import json
|
|||
|
# import requests
|
|||
|
# from flask import request, Blueprint
|
|||
|
# # from pydantic import BaseModel
|
|||
|
#
|
|||
|
# import OpenCVTool.img_zip as PicDeal
|
|||
|
# from dynamic_toekn.key_create import random_key
|
|||
|
#
|
|||
|
# API_OpenCVTool = Blueprint("API_OpenCVTool", __name__)
|
|||
|
#
|
|||
|
#
|
|||
|
# # 这个接口之前是应用于本地的,如果应用于web,应当做一些调整
|
|||
|
# # 单图处理
|
|||
|
# # @API_OpenCVTool.route('/img/zip/jpg', methods='POST')
|
|||
|
# def img_zip_jpg(img, level, outpath):
|
|||
|
# result = PicDeal.zipJPG(img, level, outpath=outpath)
|
|||
|
# state = "1"
|
|||
|
# if result == "ERROR-IMG-ZIP-JPG-WRITE":
|
|||
|
# state = "0"
|
|||
|
# if result == "ERROR-IMG-ZIP-JPG-DEAL":
|
|||
|
# state = "-1"
|
|||
|
# if result == "ERROR-IMG-ZIP-JPG-LEVEL":
|
|||
|
# state = "-2"
|
|||
|
# return {"code": state, "data": {"state": state, "result": result, 'outpath': outpath}}
|
|||
|
#
|
|||
|
#
|
|||
|
# # 多图对象
|
|||
|
# class Imgs(BaseModel):
|
|||
|
# imgs = [] # type: list[str]
|
|||
|
# level = "" # type: str
|
|||
|
# outpath = [] # type: list[str]
|
|||
|
#
|
|||
|
#
|
|||
|
# # 多图处理
|
|||
|
# # @API_OpenCVTool.route('/img/zip/jpg/many', methods='POST')
|
|||
|
# def img_zip_jpg_many(Imgs: Imgs):
|
|||
|
# print(Imgs)
|
|||
|
# result = []
|
|||
|
# for i in range(len(Imgs.imgs)):
|
|||
|
# r = PicDeal.zipJPG(Imgs.imgs[i], Imgs.level, Imgs.outpath[i])
|
|||
|
# state = "1"
|
|||
|
# if r == "ERROR-IMG-ZIP-JPG-WRITE":
|
|||
|
# state = "0"
|
|||
|
# if r == "ERROR-IMG-ZIP-JPG-DEAL":
|
|||
|
# state = "-1"
|
|||
|
# if r == "ERROR-IMG-ZIP-JPG-LEVEL":
|
|||
|
# state = "-2"
|
|||
|
# result.append({"state": state, "result": r, 'outpath': Imgs.outpath[i]})
|
|||
|
# return {"data": {"result": result}}
|
|||
|
#
|
|||
|
#
|
|||
|
# # 多图对象
|
|||
|
# class ImgObject(BaseModel):
|
|||
|
# imgs :list # type: list[str]
|
|||
|
# level :str # type: str
|
|||
|
# taskid :str # type: str
|
|||
|
#
|
|||
|
#
|
|||
|
# # 直接重构多图处理方法为web接口
|
|||
|
# # base64的方式返回结果
|
|||
|
# @API_OpenCVTool.route('/img/zip/jpg/many', methods=['POST'])
|
|||
|
# def img_zip_jpg_many_web():
|
|||
|
#
|
|||
|
# imgs = request.files
|
|||
|
# level = request.form["level"]
|
|||
|
# taskid = request.form["taskid"]
|
|||
|
# outpath = []
|
|||
|
# print(imgs)
|
|||
|
# # for i in imgs["imgs"]:
|
|||
|
# # print(i.)
|
|||
|
# # outpath.append(random_key(taskid) + ".jpg") # 关于扩展名,尝试自己去获取扩展名
|
|||
|
# # #
|
|||
|
# # result = []
|
|||
|
# # for i in range(len(Imgs.imgs)):
|
|||
|
# # r = PicDeal.zipJPG(Imgs.imgs[i], Imgs.level, outpath[i])
|
|||
|
# # state = "1"
|
|||
|
# # if r == "ERROR-IMG-ZIP-JPG-WRITE":
|
|||
|
# # state = "0"
|
|||
|
# # if r == "ERROR-IMG-ZIP-JPG-DEAL":
|
|||
|
# # state = "-1"
|
|||
|
# # if r == "ERROR-IMG-ZIP-JPG-LEVEL":
|
|||
|
# # state = "-2"
|
|||
|
# # result.append({"state": state, "result": r, 'outpath': outpath[i]})
|
|||
|
# return {"data": {"result": 0}}
|
|||
|
#
|