def scale_down(src_size, size):
    "Scales down crop size if it's larger than image size.\n\n    If width/height of the crop is larger than the width/height of the image,\n    sets the width/height to the width/height of the image.\n\n    Parameters\n    ----------\n    src_size : tuple of int\n        Size of the image in (width, height) format.\n    size : tuple of int\n        Size of the crop in (width, height) format.\n\n    Returns\n    -------\n    tuple of int\n        A tuple containing the scaled crop size in (width, height) format.\n\n    Example\n    --------\n    >>> src_size = (640,480)\n    >>> size = (720,120)\n    >>> new_size = mx.img.scale_down(src_size, size)\n    >>> new_size\n    (640,106)\n    "
    (w, h) = size
    (sw, sh) = src_size
    if (sh < h):
        (w, h) = ((float((w * sh)) / h), sh)
    if (sw < w):
        (w, h) = (sw, (float((h * sw)) / w))
    return (int(w), int(h))
Scales down crop size if it's larger than image size.

If width/height of the crop is larger than the width/height of the image,
sets the width/height to the width/height of the image.

Parameters
----------
src_size : tuple of int
    Size of the image in (width, height) format.
size : tuple of int
    Size of the crop in (width, height) format.

Returns
-------
tuple of int
    A tuple containing the scaled crop size in (width, height) format.

Example
--------
>>> src_size = (640,480)
>>> size = (720,120)
>>> new_size = mx.img.scale_down(src_size, size)
>>> new_size
(640,106)
def scale_down(src_size, size):
    "Scales down crop size if it's larger than image size.\n\n    If width/height of the crop is larger than the width/height of the image,\n    sets the width/height to the width/height of the image.\n\n    Parameters\n    ----------\n    src_size : tuple of int\n        Size of the image in (width, height) format.\n    size : tuple of int\n        Size of the crop in (width, height) format.\n\n    Returns\n    -------\n    tuple of int\n        A tuple containing the scaled crop size in (width, height) format.\n\n    Example\n    --------\n    >>> src_size = (640,480)\n    >>> size = (720,120)\n    >>> new_size = mx.img.scale_down(src_size, size)\n    >>> new_size\n    (640,106)\n    "
    (w, h) = size
    (sw, sh) = src_size
    if (sh < h):
        (w, h) = ((float((w * sh)) / h), sh)
    if (sw < w):
        (w, h) = (sw, (float((h * sw)) / w))
    return (int(w), int(h))