diff options
author | Eric <ericmabr@gmail.com> | 2023-08-26 16:23:19 -0400 |
---|---|---|
committer | Eric <ericmabr@gmail.com> | 2023-08-26 16:23:19 -0400 |
commit | 1ef04d7deab76558e69fa251ff71d37d4033d567 (patch) | |
tree | d7bd88f2c2d44e7eb6d9f1b102923b47617cb169 /src/client/views/nodes/generativeFill/GenerativeFill.tsx | |
parent | 5c6eaeffb93af172ca9e33b76fd2301d29366578 (diff) | |
parent | 8f43a98c363ff541070b100a2d4e10e505df6969 (diff) |
Merge branch 'UI_Update_Eric_Ma' of https://github.com/brown-dash/Dash-Web into UI_Update_Eric_Ma
Diffstat (limited to 'src/client/views/nodes/generativeFill/GenerativeFill.tsx')
-rw-r--r-- | src/client/views/nodes/generativeFill/GenerativeFill.tsx | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/client/views/nodes/generativeFill/GenerativeFill.tsx b/src/client/views/nodes/generativeFill/GenerativeFill.tsx index 9c03600cf..1400d0f6d 100644 --- a/src/client/views/nodes/generativeFill/GenerativeFill.tsx +++ b/src/client/views/nodes/generativeFill/GenerativeFill.tsx @@ -166,20 +166,27 @@ const GenerativeFill = ({ imageEditorOpen, imageEditorSource, imageRootDoc, addD // first load useEffect(() => { - if (!imageEditorSource || imageEditorSource === '') return; - const img = new Image(); - img.src = imageEditorSource; - currImg.current = img; - originalImg.current = img; - img.onload = () => { - const imgWidth = img.naturalWidth; - const imgHeight = img.naturalHeight; - const scale = Math.min(canvasSize / imgWidth, canvasSize / imgHeight); - const width = imgWidth * scale; - const height = imgHeight * scale; - setCanvasDims({ width, height }); + const loadInitial = async () => { + if (!imageEditorSource || imageEditorSource === '') return; + const img = new Image(); + const res = await ImageUtility.urlToBase64(imageEditorSource); + if (!res) return; + img.src = `data:image/png;base64,${res}`; + + img.onload = () => { + currImg.current = img; + originalImg.current = img; + const imgWidth = img.naturalWidth; + const imgHeight = img.naturalHeight; + const scale = Math.min(canvasSize / imgWidth, canvasSize / imgHeight); + const width = imgWidth * scale; + const height = imgHeight * scale; + setCanvasDims({ width, height }); + }; }; + loadInitial(); + // cleanup return () => { setInput(''); |