diff options
author | 不会画画的中医不是好程序员 <yfszzx@gmail.com> | 2022-10-10 12:21:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-10 12:21:25 +0000 |
commit | 1e18a5ffcc439b72adaaf425c0b79f3acb34322e (patch) | |
tree | 01f9c73c02076694a9bc3c965875646473771db8 /modules/images.py | |
parent | 23f2989799ee3911d2959cfceb74b921f20c9a51 (diff) | |
parent | a3578233395e585e68c2118d3630cb2a961d4a36 (diff) | |
download | stable-diffusion-webui-gfx803-1e18a5ffcc439b72adaaf425c0b79f3acb34322e.tar.gz stable-diffusion-webui-gfx803-1e18a5ffcc439b72adaaf425c0b79f3acb34322e.tar.bz2 stable-diffusion-webui-gfx803-1e18a5ffcc439b72adaaf425c0b79f3acb34322e.zip |
Merge branch 'AUTOMATIC1111:master' into master
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/modules/images.py b/modules/images.py index 29c5ee24..c0a90676 100644 --- a/modules/images.py +++ b/modules/images.py @@ -349,6 +349,38 @@ def get_next_sequence_number(path, basename): def save_image(image, path, basename, seed=None, prompt=None, extension='png', info=None, short_filename=False, no_prompt=False, grid=False, pnginfo_section_name='parameters', p=None, existing_info=None, forced_filename=None, suffix="", save_to_dirs=None):
+ '''Save an image.
+
+ Args:
+ image (`PIL.Image`):
+ The image to be saved.
+ path (`str`):
+ The directory to save the image. Note, the option `save_to_dirs` will make the image to be saved into a sub directory.
+ basename (`str`):
+ The base filename which will be applied to `filename pattern`.
+ seed, prompt, short_filename,
+ extension (`str`):
+ Image file extension, default is `png`.
+ pngsectionname (`str`):
+ Specify the name of the section which `info` will be saved in.
+ info (`str` or `PngImagePlugin.iTXt`):
+ PNG info chunks.
+ existing_info (`dict`):
+ Additional PNG info. `existing_info == {pngsectionname: info, ...}`
+ no_prompt:
+ TODO I don't know its meaning.
+ p (`StableDiffusionProcessing`)
+ forced_filename (`str`):
+ If specified, `basename` and filename pattern will be ignored.
+ save_to_dirs (bool):
+ If true, the image will be saved into a subdirectory of `path`.
+
+ Returns: (fullfn, txt_fullfn)
+ fullfn (`str`):
+ The full path of the saved imaged.
+ txt_fullfn (`str` or None):
+ If a text file is saved for this image, this will be its full path. Otherwise None.
+ '''
if short_filename or prompt is None or seed is None:
file_decoration = ""
elif opts.save_to_dirs:
@@ -424,7 +456,10 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i piexif.insert(exif_bytes(), fullfn_without_extension + ".jpg")
if opts.save_txt and info is not None:
- with open(f"{fullfn_without_extension}.txt", "w", encoding="utf8") as file:
+ txt_fullfn = f"{fullfn_without_extension}.txt"
+ with open(txt_fullfn, "w", encoding="utf8") as file:
file.write(info + "\n")
+ else:
+ txt_fullfn = None
- return fullfn
+ return fullfn, txt_fullfn
|