UNPKG

util-helpers

Version:

一个基于业务场景的工具方法库

29 lines (26 loc) 909 B
import { round } from 'ut2'; import divide from './divide.js'; import gcd from './gcd.js'; import loadImageWithBlob from './loadImageWithBlob.js'; import bytesToSize from './bytesToSize.js'; function calcContrast(w, h) { var n = gcd(w, h); return "".concat(divide(round(w), n), ":").concat(divide(round(h), n)); } function getImageInfo(img, ajaxOptions) { return loadImageWithBlob(img, ajaxOptions).then(function (_a) { var image = _a.image, blob = _a.blob; var width = image.width, height = image.height; return { width: width, height: height, contrast: calcContrast(width, height), measure: "".concat(width, " \u00D7 ").concat(height, " px"), size: bytesToSize(blob.size), bytes: blob.size, image: image, blob: blob }; }); } export { getImageInfo as default };