Skip to content

Image manipulation endpoints


Endpoints for performing image processing manipulations

trim_image(request) async

Crop (trim) background from the given image.

Parameters:

Name Type Description Default
request TrimImageRequest

input image

required

Returns:

Name Type Description
response TrimImageResponse

response image

Source code in src/app/routers/tools/tools.py
@router.post(path='/trim_image', response_model=schemas.TrimImageResponse)
async def trim_image(request: schemas.TrimImageRequest) -> schemas.TrimImageResponse:
    """
    Crop (trim) background from the given image.

    Parameters
    ----------
    request : schemas.TrimImageRequest
        input image

    Returns
    -------
    response : schemas.TrimImageResponse
        response image
    """
    trimmed_image = await services.trim_image(item=request, norm_thresh=request.norm_thresh,
                                              initial_thresh=request.initial_thresh)

    return schemas.TrimImageResponse(id=request.id, image=trimmed_image)