diff options
author | bobzel <zzzman@gmail.com> | 2023-08-26 13:36:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-26 13:36:56 -0400 |
commit | 603e437d4964c2f104a04f4f977802e241347344 (patch) | |
tree | ffe3e12746749f64b5d47a2c2fbafbe1056bd76a /src/client/views/nodes/generativeFill/GenerativeFill.tsx | |
parent | 1108eee6c72b1b7f74a400a7af55c2f71d09c333 (diff) | |
parent | 778ea6d9d88c06e5584b5b4d4989a011ad5424c2 (diff) |
Merge pull request #216 from brown-dash/sophie-ai-images
Image Editor fix for browndash, small icon/ui fixes
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(''); |