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
53951829
Commit
53951829
authored
Jul 08, 2023
by
AUTOMATIC1111
Committed by
GitHub
Jul 08, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11468 from NoCrypt/grid-colors-options
Add options to change colors in grid
parents
f0c62688
f74fb504
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
modules/images.py
modules/images.py
+8
-6
modules/shared.py
modules/shared.py
+4
-1
No files found.
modules/images.py
View file @
53951829
...
@@ -12,7 +12,7 @@ import re
...
@@ -12,7 +12,7 @@ import re
import
numpy
as
np
import
numpy
as
np
import
piexif
import
piexif
import
piexif.helper
import
piexif.helper
from
PIL
import
Image
,
ImageFont
,
ImageDraw
,
PngImagePlugin
from
PIL
import
Image
,
ImageFont
,
ImageDraw
,
ImageColor
,
PngImagePlugin
import
string
import
string
import
json
import
json
import
hashlib
import
hashlib
...
@@ -141,6 +141,11 @@ class GridAnnotation:
...
@@ -141,6 +141,11 @@ class GridAnnotation:
def
draw_grid_annotations
(
im
,
width
,
height
,
hor_texts
,
ver_texts
,
margin
=
0
):
def
draw_grid_annotations
(
im
,
width
,
height
,
hor_texts
,
ver_texts
,
margin
=
0
):
color_active
=
ImageColor
.
getcolor
(
opts
.
grid_text_active_color
,
'RGB'
)
color_inactive
=
ImageColor
.
getcolor
(
opts
.
grid_text_inactive_color
,
'RGB'
)
color_background
=
ImageColor
.
getcolor
(
opts
.
grid_background_color
,
'RGB'
)
def
wrap
(
drawing
,
text
,
font
,
line_length
):
def
wrap
(
drawing
,
text
,
font
,
line_length
):
lines
=
[
''
]
lines
=
[
''
]
for
word
in
text
.
split
():
for
word
in
text
.
split
():
...
@@ -170,9 +175,6 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts, margin=0):
...
@@ -170,9 +175,6 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts, margin=0):
fnt
=
get_font
(
fontsize
)
fnt
=
get_font
(
fontsize
)
color_active
=
(
0
,
0
,
0
)
color_inactive
=
(
153
,
153
,
153
)
pad_left
=
0
if
sum
([
sum
([
len
(
line
.
text
)
for
line
in
lines
])
for
lines
in
ver_texts
])
==
0
else
width
*
3
//
4
pad_left
=
0
if
sum
([
sum
([
len
(
line
.
text
)
for
line
in
lines
])
for
lines
in
ver_texts
])
==
0
else
width
*
3
//
4
cols
=
im
.
width
//
width
cols
=
im
.
width
//
width
...
@@ -181,7 +183,7 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts, margin=0):
...
@@ -181,7 +183,7 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts, margin=0):
assert
cols
==
len
(
hor_texts
),
f
'bad number of horizontal texts: {len(hor_texts)}; must be {cols}'
assert
cols
==
len
(
hor_texts
),
f
'bad number of horizontal texts: {len(hor_texts)}; must be {cols}'
assert
rows
==
len
(
ver_texts
),
f
'bad number of vertical texts: {len(ver_texts)}; must be {rows}'
assert
rows
==
len
(
ver_texts
),
f
'bad number of vertical texts: {len(ver_texts)}; must be {rows}'
calc_img
=
Image
.
new
(
"RGB"
,
(
1
,
1
),
"white"
)
calc_img
=
Image
.
new
(
"RGB"
,
(
1
,
1
),
color_background
)
calc_d
=
ImageDraw
.
Draw
(
calc_img
)
calc_d
=
ImageDraw
.
Draw
(
calc_img
)
for
texts
,
allowed_width
in
zip
(
hor_texts
+
ver_texts
,
[
width
]
*
len
(
hor_texts
)
+
[
pad_left
]
*
len
(
ver_texts
)):
for
texts
,
allowed_width
in
zip
(
hor_texts
+
ver_texts
,
[
width
]
*
len
(
hor_texts
)
+
[
pad_left
]
*
len
(
ver_texts
)):
...
@@ -202,7 +204,7 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts, margin=0):
...
@@ -202,7 +204,7 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts, margin=0):
pad_top
=
0
if
sum
(
hor_text_heights
)
==
0
else
max
(
hor_text_heights
)
+
line_spacing
*
2
pad_top
=
0
if
sum
(
hor_text_heights
)
==
0
else
max
(
hor_text_heights
)
+
line_spacing
*
2
result
=
Image
.
new
(
"RGB"
,
(
im
.
width
+
pad_left
+
margin
*
(
cols
-
1
),
im
.
height
+
pad_top
+
margin
*
(
rows
-
1
)),
"white"
)
result
=
Image
.
new
(
"RGB"
,
(
im
.
width
+
pad_left
+
margin
*
(
cols
-
1
),
im
.
height
+
pad_top
+
margin
*
(
rows
-
1
)),
color_background
)
for
row
in
range
(
rows
):
for
row
in
range
(
rows
):
for
col
in
range
(
cols
):
for
col
in
range
(
cols
):
...
...
modules/shared.py
View file @
53951829
...
@@ -320,6 +320,10 @@ options_templates.update(options_section(('saving-images', "Saving images/grids"
...
@@ -320,6 +320,10 @@ options_templates.update(options_section(('saving-images', "Saving images/grids"
"grid_prevent_empty_spots"
:
OptionInfo
(
False
,
"Prevent empty spots in grid (when set to autodetect)"
),
"grid_prevent_empty_spots"
:
OptionInfo
(
False
,
"Prevent empty spots in grid (when set to autodetect)"
),
"grid_zip_filename_pattern"
:
OptionInfo
(
""
,
"Archive filename pattern"
,
component_args
=
hide_dirs
)
.
link
(
"wiki"
,
"https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Images-Filename-Name-and-Subdirectory"
),
"grid_zip_filename_pattern"
:
OptionInfo
(
""
,
"Archive filename pattern"
,
component_args
=
hide_dirs
)
.
link
(
"wiki"
,
"https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Images-Filename-Name-and-Subdirectory"
),
"n_rows"
:
OptionInfo
(
-
1
,
"Grid row count; use -1 for autodetect and 0 for it to be same as batch size"
,
gr
.
Slider
,
{
"minimum"
:
-
1
,
"maximum"
:
16
,
"step"
:
1
}),
"n_rows"
:
OptionInfo
(
-
1
,
"Grid row count; use -1 for autodetect and 0 for it to be same as batch size"
,
gr
.
Slider
,
{
"minimum"
:
-
1
,
"maximum"
:
16
,
"step"
:
1
}),
"font"
:
OptionInfo
(
""
,
"Font for image grids that have text"
),
"grid_text_active_color"
:
OptionInfo
(
"#000000"
,
"Text color for image grids"
,
ui_components
.
FormColorPicker
,
{}),
"grid_text_inactive_color"
:
OptionInfo
(
"#999999"
,
"Inactive text color for image grids"
,
ui_components
.
FormColorPicker
,
{}),
"grid_background_color"
:
OptionInfo
(
"#ffffff"
,
"Background color for image grids"
,
ui_components
.
FormColorPicker
,
{}),
"enable_pnginfo"
:
OptionInfo
(
True
,
"Save text information about generation parameters as chunks to png files"
),
"enable_pnginfo"
:
OptionInfo
(
True
,
"Save text information about generation parameters as chunks to png files"
),
"save_txt"
:
OptionInfo
(
False
,
"Create a text file next to every image with generation parameters."
),
"save_txt"
:
OptionInfo
(
False
,
"Create a text file next to every image with generation parameters."
),
...
@@ -480,7 +484,6 @@ options_templates.update(options_section(('ui', "User interface"), {
...
@@ -480,7 +484,6 @@ options_templates.update(options_section(('ui', "User interface"), {
"do_not_show_images"
:
OptionInfo
(
False
,
"Do not show any images in results for web"
),
"do_not_show_images"
:
OptionInfo
(
False
,
"Do not show any images in results for web"
),
"send_seed"
:
OptionInfo
(
True
,
"Send seed when sending prompt or image to other interface"
),
"send_seed"
:
OptionInfo
(
True
,
"Send seed when sending prompt or image to other interface"
),
"send_size"
:
OptionInfo
(
True
,
"Send size when sending prompt or image to another interface"
),
"send_size"
:
OptionInfo
(
True
,
"Send size when sending prompt or image to another interface"
),
"font"
:
OptionInfo
(
""
,
"Font for image grids that have text"
),
"js_modal_lightbox"
:
OptionInfo
(
True
,
"Enable full page image viewer"
),
"js_modal_lightbox"
:
OptionInfo
(
True
,
"Enable full page image viewer"
),
"js_modal_lightbox_initially_zoomed"
:
OptionInfo
(
True
,
"Show images zoomed in by default in full page image viewer"
),
"js_modal_lightbox_initially_zoomed"
:
OptionInfo
(
True
,
"Show images zoomed in by default in full page image viewer"
),
"js_modal_lightbox_gamepad"
:
OptionInfo
(
False
,
"Navigate image viewer with gamepad"
),
"js_modal_lightbox_gamepad"
:
OptionInfo
(
False
,
"Navigate image viewer with gamepad"
),
...
...
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