mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-08-06 14:10:13 -03:00
feat(SaveImageLM): add add_loras_to_prompt toggle to restore legacy lora syntax line in metadata
This commit is contained in:
@@ -86,6 +86,41 @@ def test_save_image_skips_png_parameters_when_metadata_disabled_and_keeps_workfl
|
||||
assert img.info["workflow"] == json.dumps(workflow)
|
||||
|
||||
|
||||
def test_save_image_does_not_append_loras_to_prompt_by_default(monkeypatch, tmp_path):
|
||||
_configure_save_paths(monkeypatch, tmp_path)
|
||||
_configure_metadata(
|
||||
monkeypatch,
|
||||
{"prompt": "prompt text", "seed": 123, "loras": "<lora:foo:0.7>"},
|
||||
)
|
||||
|
||||
node = SaveImageLM()
|
||||
node.save_images([_make_image()], "ComfyUI", "png", id="node-1")
|
||||
|
||||
image_path = tmp_path / "sample_00001_.png"
|
||||
with Image.open(image_path) as img:
|
||||
assert "<lora:" not in img.info["parameters"]
|
||||
assert img.info["parameters"] == "prompt text\nSeed: 123, Version: ComfyUI"
|
||||
|
||||
|
||||
def test_save_image_appends_loras_to_prompt_when_enabled(monkeypatch, tmp_path):
|
||||
_configure_save_paths(monkeypatch, tmp_path)
|
||||
_configure_metadata(
|
||||
monkeypatch,
|
||||
{"prompt": "prompt text", "seed": 123, "loras": "<lora:foo:0.7>"},
|
||||
)
|
||||
|
||||
node = SaveImageLM()
|
||||
node.save_images(
|
||||
[_make_image()], "ComfyUI", "png", id="node-1", add_loras_to_prompt=True
|
||||
)
|
||||
|
||||
image_path = tmp_path / "sample_00001_.png"
|
||||
with Image.open(image_path) as img:
|
||||
assert img.info["parameters"] == (
|
||||
"prompt text\n<lora:foo:0.7>\nSeed: 123, Version: ComfyUI"
|
||||
)
|
||||
|
||||
|
||||
def test_save_image_skips_jpeg_metadata_when_disabled(monkeypatch, tmp_path):
|
||||
_configure_save_paths(monkeypatch, tmp_path)
|
||||
_configure_metadata(monkeypatch, {"prompt": "prompt text", "seed": 123})
|
||||
@@ -451,6 +486,14 @@ class TestParameterDefaultConsistency:
|
||||
assert SaveImageLM.save_images.__defaults__[5] == 0
|
||||
assert SaveImageLM.process_image.__defaults__[7] == 0
|
||||
|
||||
def test_add_loras_to_prompt_defaults_are_consistent(self):
|
||||
input_types = SaveImageLM.INPUT_TYPES()
|
||||
optional = input_types["optional"]
|
||||
|
||||
assert optional["add_loras_to_prompt"][1]["default"] is False
|
||||
assert SaveImageLM.save_images.__defaults__[-1] is False
|
||||
assert SaveImageLM.process_image.__defaults__[-1] is False
|
||||
|
||||
|
||||
def test_png_does_not_pass_webp_method_or_jpeg_subsampling(monkeypatch, tmp_path):
|
||||
_configure_save_paths(monkeypatch, tmp_path)
|
||||
|
||||
Reference in New Issue
Block a user