Skip to content

Commit

Permalink
update for #12926
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Sep 9, 2023
1 parent 329c8ab commit 3ca4655
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions modules/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,15 +661,13 @@ def _atomically_save_image(image_to_save, filename_without_extension, extension)

save_image_with_geninfo(image_to_save, info, temp_file_path, extension, existing_pnginfo=params.pnginfo, pnginfo_section_name=pnginfo_section_name)

full_file_name = filename_without_extension + extension
if shared.opts.save_images_add_number_suffix and os.path.exists(full_file_name):
count = 1
while True:
full_file_name = f"{filename_without_extension}_{count}{extension}"
if not os.path.exists(full_file_name):
break
count += 1
os.replace(temp_file_path, full_file_name)
filename = filename_without_extension + extension
if shared.opts.save_images_replace_action != "Replace":
n = 0
while os.path.exists(filename):
n += 1
filename = f"{filename_without_extension}-{n}{extension}"
os.replace(temp_file_path, filename)

fullfn_without_extension, extension = os.path.splitext(params.filename)
if hasattr(os, 'statvfs'):
Expand Down
2 changes: 1 addition & 1 deletion modules/shared_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"samples_format": OptionInfo('png', 'File format for images'),
"samples_filename_pattern": OptionInfo("", "Images filename pattern", component_args=hide_dirs).link("wiki", "https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Images-Filename-Name-and-Subdirectory"),
"save_images_add_number": OptionInfo(True, "Add number to filename when saving", component_args=hide_dirs),
"save_images_add_number_suffix": OptionInfo(True, "Add number suffix when necessary", component_args=hide_dirs).info("prevent existing image from being override"),
"save_images_replace_action": OptionInfo("Replace", "Saving the image to an existing file", gr.Radio, {"choices": ["Replace", "Add number suffix"], **hide_dirs}),
"grid_save": OptionInfo(True, "Always save all generated image grids"),
"grid_format": OptionInfo('png', 'File format for grids'),
"grid_extended_filename": OptionInfo(False, "Add extended info (seed, prompt) to filename when saving grid"),
Expand Down

0 comments on commit 3ca4655

Please sign in to comment.