Add MJ image node, GIF save, and Kling/image generator updates

Ship o1key MJ图片生成 with content/style refs and prompt flags, save-GIF with preview, Kling 4.0 helpers, plus GPT/unified image node polish and docs.
This commit is contained in:
Jony
2026-11-09 09:11:12 +08:00
parent ff1cf830fa
commit a181cc1768
40 changed files with 6711 additions and 675 deletions
+67
View File
@@ -334,5 +334,72 @@ class O1keyImageSaveTests(unittest.TestCase):
self.assertEqual(Path(output_dir, "1.png").read_bytes(), b"keep-existing")
def test_original_gif_preserves_bytes_and_marks_animated(self):
frames = [Image.new("RGB", (6, 4), color) for color in ("red", "blue", "green")]
buffer = BytesIO()
frames[0].save(
buffer,
format="GIF",
save_all=True,
append_images=frames[1:],
duration=120,
loop=0,
)
raw = buffer.getvalue()
for image in frames:
image.close()
with tempfile.TemporaryDirectory() as temp_dir, tempfile.TemporaryDirectory() as output_dir:
source = os.path.join(temp_dir, "provider.gif")
Path(source).write_bytes(raw)
results = save_temp_images(
[source],
"o1key-gif",
"原始",
output_dir,
_folder_paths(output_dir),
naming_rule="自定义前缀",
)
self.assertEqual(len(results), 1)
self.assertTrue(results[0]["filename"].endswith(".gif"))
self.assertEqual(results[0].get("media"), "gif")
self.assertTrue(results[0].get("animated"))
saved = Path(output_dir, results[0]["filename"]).read_bytes()
self.assertEqual(detect_image_format(saved), "GIF")
self.assertEqual(saved, raw)
def test_forced_png_from_gif_reencodes_first_frame(self):
frames = [Image.new("RGB", (6, 4), color) for color in ("red", "blue")]
buffer = BytesIO()
frames[0].save(
buffer,
format="GIF",
save_all=True,
append_images=frames[1:],
duration=100,
loop=0,
)
raw = buffer.getvalue()
for image in frames:
image.close()
with tempfile.TemporaryDirectory() as temp_dir, tempfile.TemporaryDirectory() as output_dir:
source = os.path.join(temp_dir, "provider.gif")
Path(source).write_bytes(raw)
results = save_temp_images(
[source],
"o1key-gif-png",
"png",
output_dir,
_folder_paths(output_dir),
naming_rule="自定义前缀",
)
self.assertTrue(results[0]["filename"].endswith(".png"))
self.assertNotEqual(results[0].get("media"), "gif")
self.assertEqual(
detect_image_format(Path(output_dir, results[0]["filename"]).read_bytes()),
"PNG",
)
if __name__ == "__main__":
unittest.main(verbosity=2)