This commit is contained in:
sjh00
2025-06-03 22:40:50 +08:00
parent 4bf55b334f
commit 49aaffbc0f
2 changed files with 14 additions and 4 deletions
+3 -2
View File
@@ -53,7 +53,7 @@ git clone https://github.com/sjh00/ComfyUI-LoadImageWithInfo.git
- `filename`:保存的文件名(不含扩展名)
- `format`:保存格式(original、avif、webp、jpg、png、tiff)
- `original_format`:原始格式(当format设为original时使用)
- `quality`:保存质量(1-100,AVIF默认80,其他默认92,png/tiff格式不受影响)
- `quality`:保存质量(1-100,AVIF默认80,其他默认95,png/tiff格式不受影响)
- `dpi`:图像DPI值
- `exif`:EXIF元数据(JSON格式字符串)
4. 节点将保存图像
@@ -120,13 +120,14 @@ SaveImageWithInfo:
### SaveImageWithInfo 节点
- 若文件名重名,则自动增加数字以区分
- 并非所有图像格式都支持EXIF数据,目前只有JPG格式支持保存EXIF数据
- 如果选择的保存格式不支持EXIF,EXIF数据将被忽略
- 如果指定的格式无法保存,将自动回退到PNG格式
- quality参数对不同格式的影响:
- JPG/JPEG:直接影响图像质量(1-100,值越高质量越好)
- PNG/TIFF:不受影响
- WEBP/AVIF:影响图像质量(1-100,值越高质量越好,AVIF最高80;若设置100则WEBP/AVIF开启无损模式)
- WEBP/AVIF:影响图像质量(1-100,值越高质量越好,AVIF高于80肉眼无区别,所以已锁定AVIF质量上限为80;若设置100则WEBP/AVIF开启无损模式)
- 其他格式:如果格式支持quality参数则使用,否则忽略
## 许可证
+11 -2
View File
@@ -136,7 +136,7 @@ class SaveImageWithInfo:
"filename": ("STRING", {"default": "image"}),
"format": (["original", "avif", "webp", "jpg", "png", "tiff"], {"default": "original"}),
"original_format": ("STRING", {"default": "png"}),
"quality": ("INT", {"default": 92, "min": 1, "max": 100, "step": 1, "display": "silder", 'tooltip': "Quality for JPEG/WebP/AVIF formats; Quality is relative to each format. \n* Example: AVIF 60 is same quality as WebP 90. \n* PNG compression is fixed at 4 and not affected by this. PNG compression times skyrocket above level 4 for zero benefits on filesize."}),
"quality": ("INT", {"default": 95, "min": 1, "max": 100, "step": 1, "display": "silder", 'tooltip': "Quality for JPEG/WebP/AVIF formats; Quality is relative to each format. \n* Example: AVIF 60 is same quality as WebP 90. \n* PNG compression is fixed at 4 and not affected by this. PNG compression times skyrocket above level 4 for zero benefits on filesize."}),
"dpi": ("INT", {"default": 96}),
"exif": ("STRING", {"default": "{}"}),
'image_preview': ('BOOLEAN', {'default': True, 'tooltip': "Turns the image preview on and off"}),
@@ -153,7 +153,7 @@ class SaveImageWithInfo:
DESCRIPTION = "Saves the input image with to your ComfyUI output directory."
type = 'output'
quality = 92
quality = 95
quality_avif = 80
# optimize_image only works for jpeg, png and TIFF, with like just 2% reduction in size; not used for PNG as it forces a level 9 compression.
optimize_image = True
@@ -175,6 +175,15 @@ class SaveImageWithInfo:
# 确保目录存在
os.makedirs(output_dir, exist_ok=True)
# 如果文件已存在,更改文件名
if os.path.exists(full_path):
base, ext = os.path.splitext(full_filename)
counter = 1
while os.path.exists(full_path):
full_filename = f"{base}_{counter}{ext}"
full_path = os.path.join(output_dir, full_filename)
counter += 1
# 处理EXIF数据
try: