From 6ac6a1a540e451822a85a45bb559693596b560e6 Mon Sep 17 00:00:00 2001 From: Evan <195604890+evan-holland-873@users.noreply.github.com> Date: Tue, 21 Jan 2025 19:50:54 -0500 Subject: [PATCH] Added save image filetype --- nodes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nodes.py b/nodes.py index cfd7dd8a453..3be0e4ac210 100644 --- a/nodes.py +++ b/nodes.py @@ -1578,7 +1578,8 @@ def INPUT_TYPES(s): return { "required": { "images": ("IMAGE", {"tooltip": "The images to save."}), - "filename_prefix": ("STRING", {"default": "ComfyUI", "tooltip": "The prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% or %Empty Latent Image.width% to include values from nodes."}) + "filename_prefix": ("STRING", {"default": "ComfyUI", "tooltip": "The prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% or %Empty Latent Image.width% to include values from nodes."}), + "file_type": ("png", "jpg", "webp", "gif") }, "hidden": { "prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO" @@ -1593,7 +1594,7 @@ def INPUT_TYPES(s): CATEGORY = "image" DESCRIPTION = "Saves the input images to your ComfyUI output directory." - def save_images(self, images, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None): + def save_images(self, images, file_type, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None): filename_prefix += self.prefix_append full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0]) results = list() @@ -1610,7 +1611,7 @@ def save_images(self, images, filename_prefix="ComfyUI", prompt=None, extra_pngi metadata.add_text(x, json.dumps(extra_pnginfo[x])) filename_with_batch_num = filename.replace("%batch_num%", str(batch_number)) - file = f"{filename_with_batch_num}_{counter:05}_.png" + file = f"{filename_with_batch_num}_{counter:05}_.{file_type}" img.save(os.path.join(full_output_folder, file), pnginfo=metadata, compress_level=self.compress_level) results.append({ "filename": file,