2023-01-28 23:09:19 +00:00
|
|
|
from logging import getLogger
|
2023-01-28 15:08:59 +00:00
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
|
|
|
|
from ..params import (
|
|
|
|
ImageParams,
|
|
|
|
StageParams,
|
|
|
|
)
|
|
|
|
from ..utils import (
|
2023-01-28 15:15:02 +00:00
|
|
|
base_join,
|
2023-01-28 15:08:59 +00:00
|
|
|
ServerContext,
|
|
|
|
)
|
|
|
|
|
2023-01-28 23:09:19 +00:00
|
|
|
logger = getLogger(__name__)
|
|
|
|
|
2023-01-28 15:08:59 +00:00
|
|
|
|
|
|
|
def persist_disk(
|
|
|
|
ctx: ServerContext,
|
2023-01-28 18:42:02 +00:00
|
|
|
_stage: StageParams,
|
|
|
|
_params: ImageParams,
|
2023-01-28 15:08:59 +00:00
|
|
|
source_image: Image.Image,
|
|
|
|
*,
|
|
|
|
output: str,
|
|
|
|
) -> Image.Image:
|
2023-01-28 15:15:02 +00:00
|
|
|
dest = base_join(ctx.output_path, output)
|
|
|
|
source_image.save(dest)
|
2023-01-28 23:09:19 +00:00
|
|
|
logger.info('saved image to %s', dest)
|
2023-01-28 15:08:59 +00:00
|
|
|
return source_image
|