def random_size_crop(src, size, area, ratio, interp=2, **kwargs):
    'Randomly crop src with size. Randomize area and aspect ratio.\n\n    Parameters\n    ----------\n    src : NDArray\n        Input image\n    size : tuple of (int, int)\n        Size of the crop formatted as (width, height).\n    area : float in (0, 1] or tuple of (float, float)\n        If tuple, minimum area and maximum area to be maintained after cropping\n        If float, minimum area to be maintained after cropping, maximum area is set to 1.0\n    ratio : tuple of (float, float)\n        Aspect ratio range as (min_aspect_ratio, max_aspect_ratio)\n    interp: int, optional, default=2\n        Interpolation method. See resize_short for details.\n    Returns\n    -------\n    NDArray\n        An `NDArray` containing the cropped image.\n    Tuple\n        A tuple (x, y, width, height) where (x, y) is top-left position of the crop in the\n        original image and (width, height) are the dimensions of the cropped image.\n\n    '
    (h, w, _) = src.shape
    src_area = (h * w)
    if ('min_area' in kwargs):
        warnings.warn('`min_area` is deprecated. Please use `area` instead.', DeprecationWarning)
        area = kwargs.pop('min_area')
    assert (not kwargs), 'unexpected keyword arguments for `random_size_crop`.'
    if isinstance(area, numeric_types):
        area = (area, 1.0)
    for _ in range(10):
        target_area = (random.uniform(area[0], area[1]) * src_area)
        new_ratio = random.uniform(*ratio)
        new_w = int(round(np.sqrt((target_area * new_ratio))))
        new_h = int(round(np.sqrt((target_area / new_ratio))))
        if (random.random() < 0.5):
            (new_h, new_w) = (new_w, new_h)
        if ((new_w <= w) and (new_h <= h)):
            x0 = random.randint(0, (w - new_w))
            y0 = random.randint(0, (h - new_h))
            out = fixed_crop(src, x0, y0, new_w, new_h, size, interp)
            return (out, (x0, y0, new_w, new_h))
    return center_crop(src, size, interp)
Randomly crop src with size. Randomize area and aspect ratio.

Parameters
----------
src : NDArray
    Input image
size : tuple of (int, int)
    Size of the crop formatted as (width, height).
area : float in (0, 1] or tuple of (float, float)
    If tuple, minimum area and maximum area to be maintained after cropping
    If float, minimum area to be maintained after cropping, maximum area is set to 1.0
ratio : tuple of (float, float)
    Aspect ratio range as (min_aspect_ratio, max_aspect_ratio)
interp: int, optional, default=2
    Interpolation method. See resize_short for details.
Returns
-------
NDArray
    An `NDArray` containing the cropped image.
Tuple
    A tuple (x, y, width, height) where (x, y) is top-left position of the crop in the
    original image and (width, height) are the dimensions of the cropped image.
def random_size_crop(src, size, area, ratio, interp=2, **kwargs):
    'Randomly crop src with size. Randomize area and aspect ratio.\n\n    Parameters\n    ----------\n    src : NDArray\n        Input image\n    size : tuple of (int, int)\n        Size of the crop formatted as (width, height).\n    area : float in (0, 1] or tuple of (float, float)\n        If tuple, minimum area and maximum area to be maintained after cropping\n        If float, minimum area to be maintained after cropping, maximum area is set to 1.0\n    ratio : tuple of (float, float)\n        Aspect ratio range as (min_aspect_ratio, max_aspect_ratio)\n    interp: int, optional, default=2\n        Interpolation method. See resize_short for details.\n    Returns\n    -------\n    NDArray\n        An `NDArray` containing the cropped image.\n    Tuple\n        A tuple (x, y, width, height) where (x, y) is top-left position of the crop in the\n        original image and (width, height) are the dimensions of the cropped image.\n\n    '
    (h, w, _) = src.shape
    src_area = (h * w)
    if ('min_area' in kwargs):
        warnings.warn('`min_area` is deprecated. Please use `area` instead.', DeprecationWarning)
        area = kwargs.pop('min_area')
    assert (not kwargs), 'unexpected keyword arguments for `random_size_crop`.'
    if isinstance(area, numeric_types):
        area = (area, 1.0)
    for _ in range(10):
        target_area = (random.uniform(area[0], area[1]) * src_area)
        new_ratio = random.uniform(*ratio)
        new_w = int(round(np.sqrt((target_area * new_ratio))))
        new_h = int(round(np.sqrt((target_area / new_ratio))))
        if (random.random() < 0.5):
            (new_h, new_w) = (new_w, new_h)
        if ((new_w <= w) and (new_h <= h)):
            x0 = random.randint(0, (w - new_w))
            y0 = random.randint(0, (h - new_h))
            out = fixed_crop(src, x0, y0, new_w, new_h, size, interp)
            return (out, (x0, y0, new_w, new_h))
    return center_crop(src, size, interp)