2023-04-11 02:15:57 +00:00
|
|
|
from logging import getLogger
|
|
|
|
from typing import List, Optional
|
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
from ..params import ImageParams, StageParams
|
|
|
|
from ..server import ServerContext
|
|
|
|
from ..worker import ProgressCallback, WorkerContext
|
2023-07-02 23:21:21 +00:00
|
|
|
from .stage import BaseStage
|
2023-04-11 02:15:57 +00:00
|
|
|
|
|
|
|
logger = getLogger(__name__)
|
|
|
|
|
|
|
|
|
2023-07-02 23:21:21 +00:00
|
|
|
class BlendLinearStage(BaseStage):
|
2023-07-01 12:10:53 +00:00
|
|
|
def run(
|
|
|
|
self,
|
|
|
|
_job: WorkerContext,
|
|
|
|
_server: ServerContext,
|
|
|
|
_stage: StageParams,
|
|
|
|
_params: ImageParams,
|
|
|
|
*,
|
|
|
|
alpha: float,
|
|
|
|
sources: Optional[List[Image.Image]] = None,
|
|
|
|
_callback: Optional[ProgressCallback] = None,
|
|
|
|
**kwargs,
|
|
|
|
) -> Image.Image:
|
|
|
|
logger.info("blending image using linear interpolation")
|
2023-04-11 02:15:57 +00:00
|
|
|
|
2023-07-01 12:10:53 +00:00
|
|
|
return Image.blend(sources[1], sources[0], alpha)
|