code: function getImageNewAspectSizes(img, max_width, max_height) {
      var img_width = this.getImageWidth(img);
      var img_height = this.getImageHeight(img);
      if (img_width === 0 || img_height === 0) {
        throw new Error('Image width or height is 0 in BunnyImage.getImageNewAspectSizes().');
      }
      var ratio = Math.min(max_width / img_width, max_height / img_height);
  
      return {
        width: Math.floor(img_width * ratio),
        height: Math.floor(img_height * ratio)
      };
    }
docs: SECTION: basic Image data math functions