// 获取 base64
const getFileBase64 = (file: RcFile): Promise<string> => {
return new Promise((resolve) => {
let reader = new FileReader();
reader.readAsDataURL(file);
reader.onloadend = (e) => {
resolve(e.target.result.toString());
};
});
};
// 尺寸
const getFileWidthAndHeight = (file: RcFile): Promise<{ w: number; h: number }> => {
return new Promise((resolve) => {
const _URL = window.URL || window.webkitURL;
const img = new Image();
img.onload = () => {
resolve({
w: img.width,
h: img.height,
});
};
img.src = _URL.createObjectURL(file);
});
};