Compare commits

...

5 Commits

Author SHA1 Message Date
molbal
f4c86eafc7
Merge 743599bd18 into 6cd35a0c5f 2026-03-13 20:29:44 +00:00
molbal
743599bd18
Enhance LoadImage to support recursive file scanning
Updated the LoadImage class to implement a recursive scan for image files with a limit and fallback to a non-recursive method if necessary.
2026-02-08 22:42:37 +01:00
molbal
382c20809b
Restore whitespace 2026-01-26 22:13:50 +01:00
molbal
27f40af5f5
Restore search aliases 2026-01-26 22:06:14 +01:00
molbal
25d4954b10
Enable recursive image loading in LoadImage node
The LoadImage node now recursively scans the input directory and all its subdirectories for images, similar to the behavior of the Load Checkpoint node.

Previously, the node only displayed images located in the root of the input folder. This made organizing and managing a large number of input images difficult.
2026-01-26 22:05:11 +01:00

View File

@ -1699,20 +1699,46 @@ class PreviewImage(SaveImage):
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
}
class LoadImage:
@classmethod
def INPUT_TYPES(s):
input_dir = folder_paths.get_input_directory()
files = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))]
files = folder_paths.filter_files_content_types(files, ["image"])
files = []
limit = 1000
recursive_scan_failed = False
# Attempt recursive scan first
try:
for root, _, file_list in os.walk(input_dir, followlinks=False):
if recursive_scan_failed:
break
image_files = folder_paths.filter_files_content_types(file_list, ["image"])
for image_file in image_files:
if len(files) >= limit:
recursive_scan_failed = True
break
path_relative = os.path.relpath(os.path.join(root, image_file), input_dir)
path_relative = path_relative.replace('\\', '/')
files.append(path_relative)
except Exception:
recursive_scan_failed = True
# Fallback to original non-recursive method if limit exceeded or error
if recursive_scan_failed or not files:
files = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))]
files = folder_paths.filter_files_content_types(files, ["image"])
return {"required":
{"image": (sorted(files), {"image_upload": True})},
{"image": (sorted(list(dict.fromkeys(files))), {"image_upload": True})},
}
CATEGORY = "image"
ESSENTIALS_CATEGORY = "Basics"
SEARCH_ALIASES = ["load image", "open image", "import image", "image input", "upload image", "read image", "image loader"]
RETURN_TYPES = ("IMAGE", "MASK")
FUNCTION = "load_image"
def load_image(self, image):