From 4844866ce4af304990125b658e1cc7e61087954a Mon Sep 17 00:00:00 2001 From: solidlime Date: Wed, 7 Jan 2026 21:42:37 +0900 Subject: [PATCH] Fix: Simplify output and add UI text display Changes: - RETURN_TYPES changed to single IMAGE output only - Removed separate width/height outputs - Added UI text display with resolution info - Returns dict with 'ui' and 'result' keys - Shows mode, resolution, and filename in UI This should fix preview display and provide better UX with resolution info shown as text in the node. --- random_image_picker.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/random_image_picker.py b/random_image_picker.py index 03edc76..d731c9f 100644 --- a/random_image_picker.py +++ b/random_image_picker.py @@ -60,7 +60,11 @@ class RandomImagePicker: } } - RETURN_TYPES = ("IMAGE", "INT", "INT") + RETURN_TYPES = ("IMAGE",) + RETURN_NAMES = ("image",) + FUNCTION = "load_image" + CATEGORY = "image" + OUTPUT_NODE = True = ("IMAGE", "INT", "INT") RETURN_NAMES = ("IMAGE", "width", "height") FUNCTION = "load_image" CATEGORY = "image" @@ -136,7 +140,7 @@ class RandomImagePicker: image_data: Base64 encoded image data from file picker (used when folder_mode=False) Returns: - Tuple of (image_tensor, width, height) + Tuple of (image_tensor,) with UI info """ if folder_mode: # Folder mode: random selection from folder_path @@ -158,7 +162,14 @@ class RandomImagePicker: print(f"[Random Image Picker] Mode: Folder") print(f"[Random Image Picker] Folder: {folder_path}") print(f"[Random Image Picker] Selected: {selected_image}") - return self.load_image_file(selected_image) + + img_tensor, width, height = self.load_image_file(selected_image) + + # Return with UI info + return { + "ui": {"text": [f"📁 Folder Mode | Resolution: {width}x{height} | File: {os.path.basename(selected_image)}"]}, + "result": (img_tensor,) + } else: # Single file mode: use file picker (image_data) if not image_data: @@ -194,7 +205,12 @@ class RandomImagePicker: print(f"[Random Image Picker] Mode: Single (File Picker)") print(f"[Random Image Picker] Loaded: {width}x{height}") - return (img_tensor, width, height) + + # Return with UI info + return { + "ui": {"text": [f"📄 Single Mode | Resolution: {width}x{height}"]}, + "result": (img_tensor,) + } except Exception as e: raise ValueError(f"Failed to load image from file picker: {str(e)}")