diff --git a/nodes/FL_ImageSelector.py b/nodes/FL_ImageSelector.py index 85aa02d..be0fd87 100644 --- a/nodes/FL_ImageSelector.py +++ b/nodes/FL_ImageSelector.py @@ -16,17 +16,30 @@ class FL_ImageSelector: CATEGORY = "🏵️Fill Nodes/Image" def select_images(self, images, indices): + # Get batch size for "last" keyword processing + batch_size = images.shape[0] + # Parse the indices string try: - # Split by comma and convert to integers - index_list = [int(idx.strip()) for idx in indices.split(',') if idx.strip()] + # Split by comma and process each index + index_parts = [idx.strip() for idx in indices.split(',') if idx.strip()] + index_list = [] + + for idx_str in index_parts: + if idx_str.lower() == "last": + # Replace "last" with the last index (batch_size - 1) + if batch_size > 0: + index_list.append(batch_size - 1) + else: + # Convert to integer + index_list.append(int(idx_str)) + except ValueError: - print("Error: Indices must be comma-separated integers") + print("Error: Indices must be comma-separated integers or 'last'") # Return the original batch if parsing fails return (images,) # Validate indices - batch_size = images.shape[0] valid_indices = [idx for idx in index_list if 0 <= idx < batch_size] if not valid_indices: diff --git a/nodes/FL_Image_Randomizer.py b/nodes/FL_Image_Randomizer.py index 8ed862f..8ffdcd4 100644 --- a/nodes/FL_Image_Randomizer.py +++ b/nodes/FL_Image_Randomizer.py @@ -17,9 +17,9 @@ class FL_ImageRandomizer: } } - RETURN_TYPES = ("IMAGE", "PATH", "IMAGE") - RETURN_NAMES = ("image_batch", "selected_path", "image_list") - OUTPUT_IS_LIST = (False, False, True) + RETURN_TYPES = ("IMAGE", "PATH", "IMAGE", "STRING") + RETURN_NAMES = ("image_batch", "selected_path", "image_list", "filename") + OUTPUT_IS_LIST = (False, False, True, False) FUNCTION = "select_media" CATEGORY = "🏵️Fill Nodes/Image" @@ -29,10 +29,12 @@ class FL_ImageRandomizer: if mode == "Image": image_tensor, selected_path = self.select_image_data(directory_path, seed, search_subdirectories) - return (image_tensor, selected_path, [image_tensor]) + filename = os.path.basename(selected_path) + return (image_tensor, selected_path, [image_tensor], filename) else: # Video mode frames_tensor, selected_path = self.select_video_data(directory_path, seed, search_subdirectories) - return (frames_tensor, selected_path, [frames_tensor]) # Video frames are already a batch, but we wrap in list for consistency + filename = os.path.basename(selected_path) + return (frames_tensor, selected_path, [frames_tensor], filename) # Video frames are already a batch, but we wrap in list for consistency def select_image_data(self, directory_path, seed, search_subdirectories=False): images = self.load_files(directory_path, search_subdirectories, file_type="image") diff --git a/pyproject.toml b/pyproject.toml index c61134d..526d50c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_fill-nodes" description = "Fill-Nodes is a versatile collection of custom nodes for ComfyUI that extends functionality across multiple domains. Features include advanced image processing (pixelation, slicing, masking), visual effects generation (glitch, halftone, pixel art), comprehensive file handling (PDF creation/extraction, Google Drive integration), AI model interfaces (GPT, DALL-E, Hugging Face), utility nodes for workflow enhancement, and specialized tools for video processing, captioning, and batch operations. The pack provides both practical workflow solutions and creative tools within a unified node collection." -version = "1.5.9" +version = "1.6.0" license = "LICENSE" dependencies = ["diffusers", "librosa", "sounddevice", "glitch_this", "PyOpenGL", "glfw", "scipy>=1.13.1", "requests", "aiohttp", "moviepy", "matplotlib", "reportlab", "openai", "PyPDF2", "pdf2image", "PyMuPDF", "reportlab", "PyPDF2", "ollama", "kornia", "opencv-python", "gdown", "open_clip_torch", "google-genai"]