LoadImage node now scans subdirectories for images#12099
Open
molbal wants to merge 4 commits intoComfy-Org:masterfrom
Open
LoadImage node now scans subdirectories for images#12099molbal wants to merge 4 commits intoComfy-Org:masterfrom
molbal wants to merge 4 commits intoComfy-Org:masterfrom
Conversation
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.
Author
Contributor
|
Updated the LoadImage class to implement a recursive scan for image files with a limit and fallback to a non-recursive method if necessary.
Author
|
Thanks for the review Christian
It is a nice to have for me (I use links a lot to make life easier when I'm dual-booting or using WSL2) but I realize it might turn into a vulnerability, so I removed it for now. (Perhaps it could be re-enabled with setting an environment variable?)
I've removed converting it twice, it now uses
Good idea, I haven't thought of that. Set a mechanishm to fall back to the non-recursive method if there are 1k+ images in total |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This pull request addresses the limitation of the LoadImage node, which currently only searches for images in the root of the input directory.
The LoadImage node was enhanced to recursively scan the input directory and all of its subdirectories for image files. This brings its behavior in line with other loader nodes (like Load Checkpoint) and allows users to better organize their input files into folders.
The implementation was changed from using os.listdir to os.walk within the INPUT_TYPES method to build the file list. The file paths displayed in the dropdown menu now include their relative path from the input directory (e.g., mydirectory/myimage.png), making them easy to identify.
I tested this change by:
This simply expands the search scope for files and uses existing path-handling functions. Performance impact should be negligible unless the input directory contains an exceptionally large number of files and folders.