From 8927de45dd0bd437c9ff4824d6fff78e4bc31334 Mon Sep 17 00:00:00 2001 From: ceruleandeep Date: Mon, 18 Nov 2024 18:30:31 +1100 Subject: [PATCH] Convert data URL to plain base64-encoded image data --- public/scripts/extensions/stable-diffusion/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js index a176f2e6e..2283d219f 100644 --- a/public/scripts/extensions/stable-diffusion/index.js +++ b/public/scripts/extensions/stable-diffusion/index.js @@ -3283,7 +3283,8 @@ async function generateComfyImage(prompt, negativePrompt, signal) { const response = await fetch(getUserAvatarUrl()); if (response.ok) { const avatarBlob = await response.blob(); - const avatarBase64 = await getBase64Async(avatarBlob); + const avatarBase64DataUrl = await getBase64Async(avatarBlob); + const avatarBase64 = avatarBase64DataUrl.split(',')[1]; workflow = workflow.replaceAll('"%user_avatar%"', JSON.stringify(avatarBase64)); } else { workflow = workflow.replaceAll('"%user_avatar%"', JSON.stringify(PNG_PIXEL)); @@ -3293,7 +3294,8 @@ async function generateComfyImage(prompt, negativePrompt, signal) { const response = await fetch(getCharacterAvatarUrl()); if (response.ok) { const avatarBlob = await response.blob(); - const avatarBase64 = await getBase64Async(avatarBlob); + const avatarBase64DataUrl = await getBase64Async(avatarBlob); + const avatarBase64 = avatarBase64DataUrl.split(',')[1]; workflow = workflow.replaceAll('"%char_avatar%"', JSON.stringify(avatarBase64)); } else { workflow = workflow.replaceAll('"%char_avatar%"', JSON.stringify(PNG_PIXEL));