code: function(maxW, maxH, curW, curH){
  			var ratio	= curH / curW;
  			if( curW >= maxW && ratio <= 1 ){ 
  				curW	= maxW;
  				curH	= maxW * ratio;
  			}else if(curH >= maxH){
  				curH	= maxH;
  				curW	= maxH / ratio;
  			}
  			return { width: curW, height: curH };
  		}
docs: to compute the width/height while keeping aspect