1
0
Fork 0
onnx-web/api/onnx_web/chain/reduce_thumbnail.py

25 lines
584 B
Python

from logging import getLogger
from PIL import Image
from ..device_pool import JobContext
from ..params import ImageParams, Size, StageParams
from ..utils import ServerContext
logger = getLogger(__name__)
def reduce_thumbnail(
_job: JobContext,
_server: ServerContext,
_stage: StageParams,
_params: ImageParams,
source_image: Image.Image,
*,
size: Size,
**kwargs,
) -> Image.Image:
image = source_image.thumbnail((size.width, size.height))
logger.info("created thumbnail with dimensions: %sx%s", image.width, image.height)
return image