From f6316ea1421dfa3515015faaed3f01d9c2406386 Mon Sep 17 00:00:00 2001 From: waltem01 Date: Wed, 21 Feb 2024 08:20:24 +0100 Subject: [PATCH] image url only --- Webserver/src/routes/image/+page.svelte | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Webserver/src/routes/image/+page.svelte b/Webserver/src/routes/image/+page.svelte index 8663162..d93f40d 100644 --- a/Webserver/src/routes/image/+page.svelte +++ b/Webserver/src/routes/image/+page.svelte @@ -22,7 +22,7 @@ h: number; } - let imageURL: string | null, lastImage: File; + let imageURL: string | null; let uploadData: UploadData, matrix: Matrix; let uploadStarted = false, submitData: SubmitData; @@ -59,7 +59,7 @@ if (!mdata.success) alert(`Error while processing '${endpoint}'!`); } - async function fileAsDataURL(file: File, data: SubmitData): Promise { + async function fileAsDataURL(data: SubmitData): Promise { return new Promise((resolve, reject) => { const img = new Image(); img.onload = () => { @@ -79,9 +79,8 @@ }; img.onerror = reject; - // Create an object URL for the file and set it as the image source - const objectURL = URL.createObjectURL(file); - img.src = objectURL; + // Load image by assigning url + img.src = imageURL!; }); } @@ -98,8 +97,7 @@ const file = input?.files?.[0]; if (!file) return; - // Load image data and file - lastImage = file; + // Load image data from file imageURL = URL.createObjectURL(file); } @@ -222,8 +220,9 @@ User uploaded {/if} + {#if uploadStarted} - {#await fileAsDataURL(lastImage, submitData)} + {#await fileAsDataURL(submitData)}

Loading image data . . .

{uploadData.elapsed} seconds elapsed.

{:then dataUrl}