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
This commit is contained in:
bezo97
2024-10-07 20:55:35 +02:00
parent d68a1116dc
commit 186ff3a78e

View File

@@ -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 {