Updates
This commit is contained in:
@@ -27,8 +27,6 @@ export default async function imageInputToBase64({
|
||||
|
||||
let imageName = finalFile.name.replace(/\..*/, "");
|
||||
|
||||
let imageDataBase64: string | undefined;
|
||||
|
||||
const MIME_TYPE = mimeType ? mimeType : finalFile.type;
|
||||
const QUALITY = 0.95;
|
||||
const MAX_WIDTH = maxWidth ? maxWidth : null;
|
||||
@@ -38,10 +36,11 @@ export default async function imageInputToBase64({
|
||||
|
||||
img.src = blobURL;
|
||||
|
||||
imageDataBase64 = await new Promise((res, rej) => {
|
||||
const imageDataBase64 = await new Promise<string>((res, rej) => {
|
||||
img.onerror = function () {
|
||||
URL.revokeObjectURL(this.src);
|
||||
window.alert("Cannot load image!");
|
||||
rej(new Error("Cannot load image"));
|
||||
};
|
||||
|
||||
img.onload = function () {
|
||||
@@ -72,7 +71,7 @@ export default async function imageInputToBase64({
|
||||
|
||||
res(srcEncoded);
|
||||
};
|
||||
});
|
||||
}).catch(() => undefined);
|
||||
|
||||
return {
|
||||
imageBase64: imageDataBase64?.replace(/.*?base64,/, ""),
|
||||
@@ -89,4 +88,4 @@ export default async function imageInputToBase64({
|
||||
imageName: undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user