aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/generativeFill/GenerativeFill.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-08-27 12:43:33 -0400
committerbobzel <zzzman@gmail.com>2023-08-27 12:43:33 -0400
commit35295e152b138e75e63161d8c644861c5c59f5a3 (patch)
treea243d33430f0b9b1b051a329b0a702a7edc2cc8e /src/client/views/nodes/generativeFill/GenerativeFill.tsx
parentf03492f21046840d51ae59de53e87b769f764a79 (diff)
parentbf1777b93be0707e17e3b3c0ca6c965facebfe14 (diff)
Merge branch 'master' into data-visualization-sarah
Diffstat (limited to 'src/client/views/nodes/generativeFill/GenerativeFill.tsx')
-rw-r--r--src/client/views/nodes/generativeFill/GenerativeFill.tsx31
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('');