From 186ff3a78e7708d47a37796d338b2df2a09ce180 Mon Sep 17 00:00:00 2001 From: bezo97 Date: Mon, 7 Oct 2024 20:55:35 +0200 Subject: [PATCH] Show dropped image in output node - blobUrl is an optional paramtere in loadGraphData - sets the preview image on SaveImage and PreviewImage nodes - works for any dropped png or webp, also from the queue --- src/scripts/app.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 691d962d5..3dd254ee2 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -2277,7 +2277,8 @@ export class ComfyApp { clean: boolean = true, restore_view: boolean = true, workflow: string | null | ComfyWorkflow = null, - { showMissingNodesDialog = true, showMissingModelsDialog = true } = {} + { showMissingNodesDialog = true, showMissingModelsDialog = true } = {}, + droppedImageBlobUrl: string | undefined = undefined ) { if (clean !== false) { this.clean() @@ -2468,6 +2469,15 @@ export class ComfyApp { } } + // Show dropped image on output nodes + if ( + droppedImageBlobUrl && + (node.type === 'SaveImage' || node.type === 'PreviewImage') + ) { + // @ts-expect-error + this.nodePreviewImages[String(node.id)] = [droppedImageBlobUrl] + } + this.#invokeExtensions('loadedGraphNode', node) } @@ -2759,7 +2769,9 @@ export class ComfyApp { JSON.parse(pngInfo.workflow), true, true, - fileName + fileName, + undefined, + URL.createObjectURL(file) ) } else if (pngInfo?.prompt) { this.loadApiJson(JSON.parse(pngInfo.prompt), fileName) @@ -2777,7 +2789,14 @@ export class ComfyApp { const prompt = pngInfo?.prompt || pngInfo?.Prompt if (workflow) { - this.loadGraphData(JSON.parse(workflow), true, true, fileName) + this.loadGraphData( + JSON.parse(workflow), + true, + true, + fileName, + undefined, + URL.createObjectURL(file) + ) } else if (prompt) { this.loadApiJson(JSON.parse(prompt), fileName) } else {