function calculateAspectRatioFit(srcWidth, srcHeight, maxWidth, maxHeight) {

    var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
    return {
        width: srcWidth * ratio,
        height: srcHeight * ratio
    };
}
/**
 * Conserve aspect ratio of the orignal region. Useful when shrinking/enlarging
 * images to fit into a certain area.
 */
Conserve aspect ratio of the orignal region. Useful when shrinking/enlarging
images to fit into a certain area.
Conserve aspect ratio of the orignal region . Useful when shrinking / enlarging images to fit into a certain area .
function calculateAspectRatioFit(srcWidth, srcHeight, maxWidth, maxHeight) {
    var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
    return {
        width: srcWidth * ratio,
        height: srcHeight * ratio
    };
}
function calculateAspectRatioFit ( srcWidth , srcHeight , maxWidth , maxHeight ) { var ratio = Math . min ( maxWidth / srcWidth , maxHeight / srcHeight ) ; return { width : srcWidth * ratio , height : srcHeight * ratio } ; }
Conserve aspect ratio of the orignal region.
Conserve aspect ratio of the orignal region .