fix: handle trailing slash in filename_prefix

When prefix ends with '/' or '\' (e.g. "comfy-txt2img/"), append
default filename "ComfyUI" so it's treated as a subdirectory path
rather than a bare filename.
This commit is contained in:
1lch2
2026-05-25 17:38:05 +08:00
parent 9c5c9d1152
commit 582df5551b
+5
View File
@@ -49,6 +49,11 @@ class SaveImageAsSDWebUI:
CATEGORY = "image"
def save_images(self, images, seed, filename_prefix="ComfyUI", image_format="png", quality=100, prompt=None, extra_pnginfo=None):
# If prefix ends with a path separator (e.g. "comfy-txt2img/"),
# treat it as a directory and append default filename "ComfyUI".
if filename_prefix.endswith('/') or filename_prefix.endswith('\\'):
filename_prefix = filename_prefix + "ComfyUI"
full_output_folder, filename, counter, subfolder, _ = folder_paths.get_save_image_path(
filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0]
)