This commit is contained in:
2026-10-01 08:02:47 +01:00
parent 6392457ffb
commit 3dc9f12ad4
104 changed files with 6536 additions and 1037 deletions
+4 -5
View File
@@ -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,
};
}
}
}