From 60b6a9f9325904a061413694d698752f04e4721c Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Wed, 23 Jul 2025 18:28:31 +0200 Subject: [PATCH] Show placeholder image when preview is disabled When the preview is disabled in the canvas widget, a 1x1 transparent PNG placeholder image is now set to node.imgs. This prevents issues with missing images and ensures consistent UI behavior. --- js/CanvasView.js | 4 ++++ pyproject.toml | 2 +- src/CanvasView.ts | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/js/CanvasView.js b/js/CanvasView.js index 79c1432..ff5bf70 100644 --- a/js/CanvasView.js +++ b/js/CanvasView.js @@ -538,6 +538,10 @@ async function createCanvasWidget(node, widget, app) { const showPreviewWidget = node.widgets.find((w) => w.name === "show_preview"); if (showPreviewWidget && !showPreviewWidget.value) { log.debug("Preview disabled, skipping updateOutput"); + const PLACEHOLDER_IMAGE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; + const placeholder = new Image(); + placeholder.src = PLACEHOLDER_IMAGE; + node.imgs = [placeholder]; return; } const triggerWidget = node.widgets.find((w) => w.name === "trigger"); diff --git a/pyproject.toml b/pyproject.toml index d35dfe8..380e0c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "layerforge" description = "Photoshop-like layered canvas editor to your ComfyUI workflow. This node is perfect for complex compositing, inpainting, and outpainting, featuring multi-layer support, masking, blend modes, and precise transformations. Includes optional AI-powered background removal for streamlined image editing." -version = "1.3.9" +version = "1.4.0" license = { text = "MIT License" } dependencies = ["torch", "torchvision", "transformers", "aiohttp", "numpy", "tqdm", "Pillow"] diff --git a/src/CanvasView.ts b/src/CanvasView.ts index cc3af63..6cf9d08 100644 --- a/src/CanvasView.ts +++ b/src/CanvasView.ts @@ -577,6 +577,10 @@ async function createCanvasWidget(node: ComfyNode, widget: any, app: ComfyApp): const showPreviewWidget = node.widgets.find((w) => w.name === "show_preview"); if (showPreviewWidget && !showPreviewWidget.value) { log.debug("Preview disabled, skipping updateOutput"); + const PLACEHOLDER_IMAGE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; + const placeholder = new Image(); + placeholder.src = PLACEHOLDER_IMAGE; + node.imgs = [placeholder]; return; }