diff --git a/src/nodes/helpers.py b/src/nodes/helpers.py index 3395e79..8843821 100644 --- a/src/nodes/helpers.py +++ b/src/nodes/helpers.py @@ -140,6 +140,8 @@ def load_image_wrapper(file_name, embed_transparency, disp_name=None, show_previ def save_image(images, filenames, prompt=None, extra_pnginfo=None, compress_level=4): if isinstance(filenames, str): + if not filenames: + raise ValueError("You must provide a file name") filenames = [filenames] B = images.shape[0] if len(filenames) != B: diff --git a/src/nodes/nodes_img.py b/src/nodes/nodes_img.py index 18be93e..b8f93ed 100644 --- a/src/nodes/nodes_img.py +++ b/src/nodes/nodes_img.py @@ -307,7 +307,7 @@ class ImageSave: return { "required": { "image": ("IMAGE", {"tooltip": "The images to save."}), - "filename": ("STRING", {"default": "ComfyUI", "tooltip": "The file name for the image"}) + "filename": ("STRING", {"default": "", "tooltip": "The file name for the image"}) }, "hidden": { "prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO" @@ -329,6 +329,31 @@ class ImageSave: return () +class MaskSave: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "mask": ("MASK", {"tooltip": "The mask to save."}), + "filename": ("STRING", {"default": "", "tooltip": "The file name for the image"}) + }, + } + + RETURN_TYPES = () + FUNCTION = "execute" + + OUTPUT_NODE = True + + CATEGORY = BASE_CATEGORY + "/" + IO_CATEGORY + DESCRIPTION = ("Saves a mask to an arbitrary path") + UNIQUE_NAME = "SET_MaskSave" + DISPLAY_NAME = "Save Mask to Path" + + def execute(self, mask, filename): + save_image(mask, filename) + return () + + class ImageDataset: """ A ComfyUI node to prepare lists of images for validation tasks,