code: function getNewImageDimentions(img, width, height) {
      var detImg = img.width / img.height;
      if (width > 0 && height > 0) {
        // 同时指定了宽高，按原图缩放
        if (width / height > detImg) {
          height = width / detImg;
        } else {
          width = height * detImg;
        }
        return [ width, height ];
      } else if (width > 0) {
        // 只指定宽度的情况
        return [ width, width / detImg ];
      } else if (height > 0) {
        // 只指定高度的情况
        return [ height * detImg, height ];
      } else {
        // 否则原 size 返回
        return [ img.width, img.height ];
      }
    }
docs: 计算新图片宽高
  @private
  @param  {Image}  img    an <img> or Image() or <canvas>
  @param  {number} width  output image width
  @param  {number} height output image height
  @return {array<number>} [ width, height ]