Spaces:
Sleeping
Sleeping
File size: 1,407 Bytes
fba6023 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | from __future__ import annotations
from fastapi import APIRouter, Request
from app.api.media import execute_operation
from app.core.response import SuccessResponse
from app.operations.concat import image_sequence, image_slideshow, image_to_video
from app.operations.convert import convert_image
from app.operations.crop import crop_image
from app.operations.resize import resize_image
from app.operations.watermark import overlay_image, watermark_image
from app.services.media_service import Operation
router = APIRouter(prefix="/v1/image", tags=["image"])
def operation_route(path: str, name: str, operation: Operation) -> None:
async def endpoint(request: Request) -> SuccessResponse:
return await execute_operation(request, name, operation)
endpoint.__name__ = name.replace(".", "_")
router.add_api_route(
path, endpoint, methods=["POST"], response_model=SuccessResponse, name=name
)
operation_route("/resize", "image.resize", resize_image)
operation_route("/crop", "image.crop", crop_image)
operation_route("/convert", "image.convert", convert_image)
operation_route("/slideshow", "image.slideshow", image_slideshow)
operation_route("/sequence", "image.sequence", image_sequence)
operation_route("/video", "image.video", image_to_video)
operation_route("/watermark", "image.watermark", watermark_image)
operation_route("/overlay", "image.overlay", overlay_image)
|