

if (window.Evri == undefined) Evri = {};

Evri.Image = function(htmlImage, maxWidth, maxHeight) {
  this.htmlImage = htmlImage;
  var height = this.htmlImage.height;
  var width = this.htmlImage.width;

  var ratio = height / width;
  var ratio2 = width / height;

  if (ratio > ratio2) {
    // portrait
    // fit width, crop height, position top
    this.htmlImage.style.width = maxWidth + 'px';
  } else {
    // landscape
    // fit height, crop width, position center
    this.htmlImage.style.height = maxHeight + 'px';
    var newWidth = this.htmlImage.width;
    this.htmlImage.style.position = 'relative';
    $(this.htmlImage).css('left', -Math.floor((newWidth - maxWidth)/2) + 'px');
  }

}




