Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
53951829
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
11 个月 前同步成功
通知
1758
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
53951829
编写于
7月 08, 2023
作者:
A
AUTOMATIC1111
提交者:
GitHub
7月 08, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11468 from NoCrypt/grid-colors-options
Add options to change colors in grid
上级
f0c62688
f74fb504
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
7 deletion
+12
-7
modules/images.py
modules/images.py
+8
-6
modules/shared.py
modules/shared.py
+4
-1
未找到文件。
modules/images.py
浏览文件 @
53951829
...
...
@@ -12,7 +12,7 @@ import re
import
numpy
as
np
import
piexif
import
piexif.helper
from
PIL
import
Image
,
ImageFont
,
ImageDraw
,
PngImagePlugin
from
PIL
import
Image
,
ImageFont
,
ImageDraw
,
ImageColor
,
PngImagePlugin
import
string
import
json
import
hashlib
...
...
@@ -141,6 +141,11 @@ class GridAnnotation:
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
):
lines
=
[
''
]
for
word
in
text
.
split
():
...
...
@@ -170,9 +175,6 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts, margin=0):
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
cols
=
im
.
width
//
width
...
...
@@ -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
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
)
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):
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
col
in
range
(
cols
):
...
...
modules/shared.py
浏览文件 @
53951829
...
...
@@ -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_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
}),
"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"
),
"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"), {
"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_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_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"
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录