def calc_resize(max_size, curr_size, min_size=(0, 0)):
    """
    Calculate if resize is required based on the max size desired
    and the current size

    :param max_size: tuple of (width, height)
    :param curr_size: tuple of (width, height)
    :param min_size: tuple of (width, height)
    :return:
    """
    max_width, max_height = max_size or (0, 0)
    min_width, min_height = min_size or (0, 0)

    if (max_width and min_width > max_width) or (
        max_height and min_height > max_height
    ):
        raise ValueError("Invalid min / max sizes.")

    orig_width, orig_height = curr_size
    if (
        max_width
        and max_height
        and (orig_width > max_width or orig_height > max_height)
    ):
        resize_factor = min(
            1.0 * max_width / orig_width, 1.0 * max_height / orig_height
        )
        new_width = int(resize_factor * orig_width)
        new_height = int(resize_factor * orig_height)
        return new_width, new_height

    elif (
        min_width
        and min_height
        and (orig_width < min_width or orig_height < min_height)
    ):
        resize_factor = max(
            1.0 * min_width / orig_width, 1.0 * min_height / orig_height
        )
        new_width = int(resize_factor * orig_width)
        new_height = int(resize_factor * orig_height)
        return new_width, new_height

    Calculate if resize is required based on the max size desired
    and the current size

    :param max_size: tuple of (width, height)
    :param curr_size: tuple of (width, height)
    :param min_size: tuple of (width, height)
    :return:
    
instagrapi/image_util.py