base64 图片计算大小 bytes
const base64toBlob = (dataURI: string) => {
try {
const matches = dataURI.match(/data:(.+);/);
if (!matches || matches.length < 1) return null;
const imgType = matches[1];
const byteString = atob(dataURI.split(',')[1]);
const ab = new ArrayBuffer(byteString.length);
const ia = new Uint8Array(ab);
for (let i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], { type: imgType });
} catch (e) {
return null;
}
};