Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@filerobot/utils / lib / getImgFileDimensions.js
Size: Mime:
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var getImgFileDimensions = function getImgFileDimensions(imgFile) {
  return new Promise(function (resolve) {
    var isFileNotSrcString = _typeof(imgFile) === 'object';
    var tempImgUrl = isFileNotSrcString ? URL.createObjectURL(imgFile) : imgFile;
    var image = new Image();
    image.src = tempImgUrl;
    image.onload = function () {
      resolve({
        width: image.width,
        height: image.height
      });
      if (isFileNotSrcString) {
        URL.revokeObjectURL(tempImgUrl);
      }
    };
    image.onerror = function () {
      console.warn("Error in recognizing image dimensions for: \"".concat(tempImgUrl, "\""));
      if (isFileNotSrcString) {
        URL.revokeObjectURL(tempImgUrl);
      }
    };
  });
};
export default getImgFileDimensions;