def expand_box_by_pad(box, max_size, padding_size):
    """
    Expand a bounding box by adding padding.

    Args:
        box (list): The bounding box to be expanded in the format [left, upper, right, lower].
        max_size (tuple): The maximum size of the bounding box in the format (max_width, max_height).
        padding_size (int): The size of the padding to add to each side of the bounding box.

    Returns:
        list: The expanded bounding box in the format [left, upper, right, lower].
    """
    expanded_box = [
        max(0, box[0] - padding_size),
        max(0, box[1] - padding_size),
        min(max_size[0], box[2] + padding_size),
        min(max_size[1], box[3] + padding_size),
    ]
    return expanded_box

    Expand a bounding box by adding padding.

    Args:
        box (list): The bounding box to be expanded in the format [left, upper, right, lower].
        max_size (tuple): The maximum size of the bounding box in the format (max_width, max_height).
        padding_size (int): The size of the padding to add to each side of the bounding box.

    Returns:
        list: The expanded bounding box in the format [left, upper, right, lower].
    
scripts/easyphoto_utils/tryon_utils.py