The images output is never filled, and any link from it fails at runtime. This also blocks the node inside ComfyUI's native Start Loop / End Loop, where a node in the loop body must reach End Loop to pass validation and needs a working output to connect to its terminations input. Two optional inputs share one socket, so image_a is preferred and image_b is the fallback.
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
from nodes import PreviewImage
|
|
|
|
from .constants import get_category, get_name
|
|
|
|
|
|
class RgthreeImageComparer(PreviewImage):
|
|
"""A node that compares two images in the UI."""
|
|
|
|
NAME = get_name('Image Comparer')
|
|
CATEGORY = get_category()
|
|
FUNCTION = "compare_images"
|
|
DESCRIPTION = "Compares two images with a hover slider, or click from properties."
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls): # pylint: disable = invalid-name, missing-function-docstring
|
|
return {
|
|
"required": {},
|
|
"optional": {
|
|
"image_a": ("IMAGE",),
|
|
"image_b": ("IMAGE",),
|
|
},
|
|
"hidden": {
|
|
"prompt": "PROMPT",
|
|
"extra_pnginfo": "EXTRA_PNGINFO"
|
|
},
|
|
}
|
|
|
|
def compare_images(self,
|
|
image_a=None,
|
|
image_b=None,
|
|
filename_prefix="rgthree.compare.",
|
|
prompt=None,
|
|
extra_pnginfo=None):
|
|
|
|
result = { "ui": { "a_images":[], "b_images": [] } }
|
|
if image_a is not None and len(image_a) > 0:
|
|
result['ui']['a_images'] = self.save_images(image_a, filename_prefix, prompt, extra_pnginfo)['ui']['images']
|
|
|
|
if image_b is not None and len(image_b) > 0:
|
|
result['ui']['b_images'] = self.save_images(image_b, filename_prefix, prompt, extra_pnginfo)['ui']['images']
|
|
|
|
# RETURN_TYPES is inherited from SaveImage, so the node advertises an IMAGE
|
|
# output. Without a 'result' key it stays empty and any link from it fails.
|
|
result['result'] = (image_a if image_a is not None else image_b,)
|
|
return result |