diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-08 11:51:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-08 11:51:50 +0000 |
commit | 539518292ec4a8a138ddb95195233840311f3ee6 (patch) | |
tree | a5d81d402c9e15906b5e525f57b5298952a895e5 /modules/images.py | |
parent | f0c62688d26d612cb39a919cc77c86772f8b1df7 (diff) | |
parent | f74fb5049506b85a98b02b1c2fd7361e9f751980 (diff) | |
download | stable-diffusion-webui-gfx803-539518292ec4a8a138ddb95195233840311f3ee6.tar.gz stable-diffusion-webui-gfx803-539518292ec4a8a138ddb95195233840311f3ee6.tar.bz2 stable-diffusion-webui-gfx803-539518292ec4a8a138ddb95195233840311f3ee6.zip |
Merge pull request #11468 from NoCrypt/grid-colors-options
Add options to change colors in grid
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/images.py b/modules/images.py index 9a5d9585..b5412548 100644 --- a/modules/images.py +++ b/modules/images.py @@ -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):
|