Browse Source

Add a way to overwrite images when uploading.

pull/652/head
comfyanonymous 2 years ago
parent
commit
8ea165dd1e
  1. 4
      server.py

4
server.py

@ -127,6 +127,7 @@ class PromptServer():
def image_upload(post, image_save_function=None):
image = post.get("image")
overwrite = post.get("overwrite")
image_upload_type = post.get("type")
upload_dir = get_dir_by_type(image_upload_type)
@ -148,6 +149,9 @@ class PromptServer():
split = os.path.splitext(filename)
filepath = os.path.join(full_output_folder, filename)
if overwrite is not None and (overwrite == "true" or overwrite == "1"):
pass
else:
i = 1
while os.path.exists(filepath):
filename = f"{split[0]} ({i}){split[1]}"

Loading…
Cancel
Save