Publish current ComfyUI O1Key code baseline

Replace the prior release tree with the current plugin, frontend, tests, and documentation. Document retired node IDs and the public Gitea update source.
This commit is contained in:
Jony
2026-09-24 19:56:48 +08:00
parent 3e337722ab
commit ba920f2b66
183 changed files with 49496 additions and 9934 deletions
+53 -9
View File
@@ -27,8 +27,15 @@ class SaveImageFormat:
"图像": ("IMAGE",),
"文件名前缀": ("STRING", {"default": "ComfyUI"}),
"输出格式": (cls.FORMATS, {"default": "PNG"}),
"质量": ("INT", {
"default": 100, "min": 1, "max": 100, "step": 1,
"tooltip": "图片质量。100=不压缩(JPEG 最高质量 / WebP 无损);"
"小于 100 时按该数值压缩(如 90),仅对 JPEG / WebP 生效。",
}),
},
"optional": {
"保存路径": ("STRING", {"default": ""}),
},
"optional": {},
"hidden": {
"prompt": "PROMPT",
"extra_pnginfo": "EXTRA_PNGINFO",
@@ -43,20 +50,51 @@ class SaveImageFormat:
_EXT_MAP = {"PNG": ".png", "JPEG": ".jpg", "WebP": ".webp"}
@classmethod
def IS_CHANGED(cls, 图像=None, **kwargs):
"""保存节点属于有副作用的输出节点,不能复用上次的缓存结果。"""
return float("nan")
def save_images(self, 图像=None, 文件名前缀="ComfyUI", 输出格式="PNG",
prompt=None, extra_pnginfo=None):
质量=100, 保存路径="", prompt=None, extra_pnginfo=None):
images = 图像
filename_prefix = 文件名前缀
format = 输出格式
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]
)
quality = int(质量)
custom_dir = (保存路径 or "").strip()
if custom_dir:
# 保存到用户指定的文件夹。自定义路径不会经过
# folder_paths.get_save_image_path(),因此需要在此处自行避让重名。
full_output_folder = custom_dir
os.makedirs(full_output_folder, exist_ok=True)
filename = filename_prefix
counter = 1
subfolder = ""
else:
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]
)
ext = self._EXT_MAP.get(format, ".png")
results = []
# 为整个输入批次预留一段连续编号,避免重复运行时覆盖已有文件。
# 默认 output 路径和自定义保存路径都在这里复核一次;这样即使外部
# 编号器返回了已使用的计数,也不会覆盖。兼容 %batch_num% 占位符。
while any(
os.path.exists(
os.path.join(
full_output_folder,
f"{filename.replace('%batch_num%', str(batch_number))}_{counter + batch_number:05}_{ext}",
)
)
for batch_number in range(len(images))
):
counter += 1
for batch_number, image in enumerate(images):
i = 255.0 * image.cpu().numpy()
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
@@ -80,9 +118,15 @@ class SaveImageFormat:
elif format == "JPEG":
if img.mode == "RGBA":
img = img.convert("RGB")
img.save(filepath, quality=100, optimize=True)
if quality >= 100:
img.save(filepath, quality=100, optimize=True)
else:
img.save(filepath, quality=quality, optimize=True)
elif format == "WebP":
img.save(filepath, lossless=True)
if quality >= 100:
img.save(filepath, lossless=True)
else:
img.save(filepath, quality=quality, method=6)
results.append({
"filename": file,