Repository URL to install this package:
|
Version:
3.12.2 ▾
|
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;