2023-01-29 21:23:01 +00:00
|
|
|
from logging import getLogger
|
2023-02-05 13:53:26 +00:00
|
|
|
|
2023-01-29 21:23:01 +00:00
|
|
|
from PIL import Image
|
|
|
|
|
2023-02-05 13:53:26 +00:00
|
|
|
from ..params import ImageParams, Size, StageParams
|
2023-02-14 00:04:46 +00:00
|
|
|
from ..server.device_pool import JobContext
|
2023-02-05 13:53:26 +00:00
|
|
|
from ..utils import ServerContext
|
2023-01-29 21:23:01 +00:00
|
|
|
|
|
|
|
logger = getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
def reduce_thumbnail(
|
2023-02-05 13:53:26 +00:00
|
|
|
_job: JobContext,
|
|
|
|
_server: ServerContext,
|
2023-01-29 21:23:01 +00:00
|
|
|
_stage: StageParams,
|
|
|
|
_params: ImageParams,
|
|
|
|
source_image: Image.Image,
|
|
|
|
*,
|
|
|
|
size: Size,
|
|
|
|
**kwargs,
|
|
|
|
) -> Image.Image:
|
2023-02-06 23:13:37 +00:00
|
|
|
image = source_image.copy()
|
|
|
|
image = image.thumbnail((size.width, size.height))
|
2023-02-05 13:53:26 +00:00
|
|
|
logger.info("created thumbnail with dimensions: %sx%s", image.width, image.height)
|
2023-01-29 21:23:01 +00:00
|
|
|
return image
|