Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
eed58279
Commit
eed58279
authored
Jan 04, 2023
by
AUTOMATIC1111
Committed by
GitHub
Jan 04, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3791 from shirayu/fix/filename
Truncate too long filename (Fix #705)
parents
4ae960b0
c4b5ca57
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
modules/images.py
modules/images.py
+12
-4
No files found.
modules/images.py
View file @
eed58279
...
...
@@ -447,6 +447,14 @@ def get_next_sequence_number(path, basename):
return
result
+
1
def
truncate_fullpath
(
full_path
,
encoding
=
'utf-8'
):
dir_name
,
full_name
=
os
.
path
.
split
(
full_path
)
file_name
,
file_ext
=
os
.
path
.
splitext
(
full_name
)
max_length
=
os
.
statvfs
(
dir_name
)
.
f_namemax
file_name_truncated
=
file_name
.
encode
(
encoding
)[:
max_length
-
len
(
file_ext
)]
.
decode
(
encoding
,
'ignore'
)
return
os
.
path
.
join
(
dir_name
,
file_name_truncated
+
file_ext
)
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.
...
...
@@ -487,7 +495,7 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
if
save_to_dirs
:
dirname
=
namegen
.
apply
(
opts
.
directories_filename_pattern
or
"[prompt_words]"
)
.
lstrip
(
' '
)
.
rstrip
(
'
\\
/'
)
path
=
os
.
path
.
join
(
path
,
dirname
)
path
=
truncate_fullpath
(
os
.
path
.
join
(
path
,
dirname
)
)
os
.
makedirs
(
path
,
exist_ok
=
True
)
...
...
@@ -511,13 +519,13 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
fullfn
=
None
for
i
in
range
(
500
):
fn
=
f
"{basecount + i:05}"
if
basename
==
''
else
f
"{basename}-{basecount + i:04}"
fullfn
=
os
.
path
.
join
(
path
,
f
"{fn}{file_decoration}.{extension}"
)
fullfn
=
truncate_fullpath
(
os
.
path
.
join
(
path
,
f
"{fn}{file_decoration}.{extension}"
)
)
if
not
os
.
path
.
exists
(
fullfn
):
break
else
:
fullfn
=
os
.
path
.
join
(
path
,
f
"{file_decoration}.{extension}"
)
fullfn
=
truncate_fullpath
(
os
.
path
.
join
(
path
,
f
"{file_decoration}.{extension}"
)
)
else
:
fullfn
=
os
.
path
.
join
(
path
,
f
"{forced_filename}.{extension}"
)
fullfn
=
truncate_fullpath
(
os
.
path
.
join
(
path
,
f
"{forced_filename}.{extension}"
)
)
pnginfo
=
existing_info
or
{}
if
info
is
not
None
:
...
...
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