# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
Transforms.ImageResizer
"""

import numbers

from ..utils.entrypoints import EntryPoint
from ..utils.utils import try_set, unlist


def transforms_imageresizer(
        column,
        data,
        output_data=None,
        model=None,
        image_width=0,
        image_height=0,
        resizing='IsoCrop',
        crop_anchor='Center',
        **params):
    """
    **Description**
        Scales an image to specified dimensions using one of the three scale
        types: isotropic with padding, isotropic with cropping or
        anisotropic. In case of isotropic padding, transparent color
        is used to pad resulting image.

    :param column: New column definition(s) (optional form: name:src)
        (inputs).
    :param data: Input dataset (inputs).
    :param image_width: Resized width of the image (inputs).
    :param image_height: Resized height of the image (inputs).
    :param resizing: Resizing method (inputs).
    :param crop_anchor: Anchor for cropping (inputs).
    :param output_data: Transformed dataset (outputs).
    :param model: Transform model (outputs).
    """

    entrypoint_name = 'Transforms.ImageResizer'
    inputs = {}
    outputs = {}

    if column is not None:
        inputs['Column'] = try_set(
            obj=column,
            none_acceptable=False,
            is_of_type=list,
            is_column=True)
    if data is not None:
        inputs['Data'] = try_set(
            obj=data,
            none_acceptable=False,
            is_of_type=str)
    if image_width is not None:
        inputs['ImageWidth'] = try_set(
            obj=image_width,
            none_acceptable=False,
            is_of_type=numbers.Real)
    if image_height is not None:
        inputs['ImageHeight'] = try_set(
            obj=image_height,
            none_acceptable=False,
            is_of_type=numbers.Real)
    if resizing is not None:
        inputs['Resizing'] = try_set(
            obj=resizing,
            none_acceptable=True,
            is_of_type=str,
            values=[
                'IsoPad',
                'IsoCrop'])
    if crop_anchor is not None:
        inputs['CropAnchor'] = try_set(
            obj=crop_anchor,
            none_acceptable=True,
            is_of_type=str,
            values=[
                'Right',
                'Left',
                'Top',
                'Bottom',
                'Center'])
    if output_data is not None:
        outputs['OutputData'] = try_set(
            obj=output_data,
            none_acceptable=False,
            is_of_type=str)
    if model is not None:
        outputs['Model'] = try_set(
            obj=model,
            none_acceptable=False,
            is_of_type=str)

    input_variables = {
        x for x in unlist(inputs.values())
        if isinstance(x, str) and x.startswith("$")}
    output_variables = {
        x for x in unlist(outputs.values())
        if isinstance(x, str) and x.startswith("$")}

    entrypoint = EntryPoint(
        name=entrypoint_name, inputs=inputs, outputs=outputs,
        input_variables=input_variables,
        output_variables=output_variables)
    return entrypoint
