Adopt Pixaroma save image preview features

This commit is contained in:
2026-10-21 16:08:56 +00:00
parent 494670ded0
commit 36c4537be7
4 changed files with 52 additions and 5 deletions
+21 -1
View File
@@ -151,7 +151,27 @@ class DumasSaveImageNode:
def save_images(self, images, folder, pattern, format, quality, embed_workflow, save_on_run,
name="", name_2="", prompt=None, extra_pnginfo=None, **_kwargs):
if not save_on_run:
return {"ui": {"images": []}}
# Match the preview/save split used by Pixaroma: Preview mode must
# still produce visible, temporary images, but must not write to
# the selected destination folder.
temp_dir = Path(folder_paths.get_temp_directory()).resolve()
temp_dir.mkdir(parents=True, exist_ok=True)
preview_images = []
preview_format = str(format or "png").lower()
extension = ".jpg" if preview_format == "jpg" else (
".webp" if preview_format == "webp" else ".png"
)
for index, image in enumerate(images):
path = temp_dir / f"dumas_save_preview_{uuid.uuid4().hex}{extension}"
pil = _image_to_pil(image)
if preview_format == "jpg":
pil.convert("RGB").save(path, "JPEG", quality=max(1, min(100, int(quality))))
elif preview_format == "webp":
pil.save(path, "WEBP", quality=max(1, min(100, int(quality))))
else:
pil.save(path, "PNG", pnginfo=_build_pnginfo(prompt, extra_pnginfo) if embed_workflow else None)
preview_images.append({"filename": path.name, "subfolder": "", "type": "temp"})
return {"ui": {"images": preview_images}}
output_dir = Path(folder_paths.get_output_directory()).resolve()
base = Path(folder).expanduser().resolve() if str(folder or "").strip() else output_dir
base.mkdir(parents=True, exist_ok=True)