Skip to content

Commit

Permalink
不覆盖文件
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowcz007 committed Jan 26, 2024
1 parent eba49f3 commit a935793
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions nodes/ImageNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import json,io
from comfy.cli_args import args
import cv2
import math
import math,glob
from .Watcher import FolderWatcher

class AnyType(str):
Expand Down Expand Up @@ -2272,6 +2272,16 @@ def save_images(self, images,file_path , prompt=None, extra_pnginfo=None):
else:
print("目录已存在")

# 使用glob模块获取当前目录下的所有文件
if file_path=="":
files = glob.glob(full_output_folder + '/*')
else:
files = glob.glob(file_path + '/*')
# 统计文件数量
file_count = len(files)
counter+=file_count
print('统计文件数量',file_count,counter)

results = list()
for image in images:
i = 255. * image.cpu().numpy()
Expand All @@ -2286,6 +2296,7 @@ def save_images(self, images,file_path , prompt=None, extra_pnginfo=None):
metadata.add_text(x, json.dumps(extra_pnginfo[x]))

file = f"{filename}_{counter:05}_.png"

if file_path=="":
img.save(os.path.join(full_output_folder, file), pnginfo=metadata, compress_level=self.compress_level)
results.append({
Expand All @@ -2303,4 +2314,4 @@ def save_images(self, images,file_path , prompt=None, extra_pnginfo=None):
})
counter += 1

return
return ()

0 comments on commit a935793

Please sign in to comment.