Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
14192c5b
Commit
14192c5b
authored
Oct 09, 2022
by
aoirusann
Committed by
AUTOMATIC1111
Oct 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support `Download` for txt files.
parent
5ab7e88d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
3 deletions
+41
-3
images.py
modules/images.py
+37
-2
ui.py
modules/ui.py
+4
-1
No files found.
modules/images.py
View file @
14192c5b
...
...
@@ -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
modules/ui.py
View file @
14192c5b
...
...
@@ -138,11 +138,14 @@ def save_files(js_data, images, do_make_zip, index):
is_grid
=
image_index
<
p
.
index_of_first_image
i
=
0
if
is_grid
else
(
image_index
-
p
.
index_of_first_image
)
fullfn
=
save_image
(
image
,
path
,
""
,
seed
=
p
.
all_seeds
[
i
],
prompt
=
p
.
all_prompts
[
i
],
extension
=
extension
,
info
=
p
.
infotexts
[
image_index
],
grid
=
is_grid
,
p
=
p
,
save_to_dirs
=
save_to_dirs
)
fullfn
,
txt_fullfn
=
save_image
(
image
,
path
,
""
,
seed
=
p
.
all_seeds
[
i
],
prompt
=
p
.
all_prompts
[
i
],
extension
=
extension
,
info
=
p
.
infotexts
[
image_index
],
grid
=
is_grid
,
p
=
p
,
save_to_dirs
=
save_to_dirs
)
filename
=
os
.
path
.
relpath
(
fullfn
,
path
)
filenames
.
append
(
filename
)
fullfns
.
append
(
fullfn
)
if
txt_fullfn
:
filenames
.
append
(
os
.
path
.
basename
(
txt_fullfn
))
fullfns
.
append
(
txt_fullfn
)
writer
.
writerow
([
data
[
"prompt"
],
data
[
"seed"
],
data
[
"width"
],
data
[
"height"
],
data
[
"sampler"
],
data
[
"cfg_scale"
],
data
[
"steps"
],
filenames
[
0
],
data
[
"negative_prompt"
]])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment