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
10137589
Commit
10137589
authored
May 28, 2023
by
Aarni Koskela
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark caption_image_overlay's textfont as deprecated; fix #10778
parent
b957dcfe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
modules/textual_inversion/image_embedding.py
modules/textual_inversion/image_embedding.py
+13
-8
No files found.
modules/textual_inversion/image_embedding.py
View file @
10137589
import
base64
import
json
import
warnings
import
numpy
as
np
import
zlib
from
PIL
import
Image
,
ImageDraw
,
ImageFont
from
PIL
import
Image
,
ImageDraw
import
torch
...
...
@@ -129,14 +131,17 @@ def extract_image_data_embed(image):
def
caption_image_overlay
(
srcimage
,
title
,
footerLeft
,
footerMid
,
footerRight
,
textfont
=
None
):
from
modules.images
import
get_font
if
textfont
:
warnings
.
warn
(
'passing in a textfont to caption_image_overlay is deprecated and does nothing'
,
DeprecationWarning
,
stacklevel
=
2
,
)
from
math
import
cos
image
=
srcimage
.
copy
()
fontsize
=
32
if
textfont
is
None
:
from
modules.images
import
get_font
textfont
=
get_font
(
fontsize
)
factor
=
1.5
gradient
=
Image
.
new
(
'RGBA'
,
(
1
,
image
.
size
[
1
]),
color
=
(
0
,
0
,
0
,
0
))
for
y
in
range
(
image
.
size
[
1
]):
...
...
@@ -147,12 +152,12 @@ def caption_image_overlay(srcimage, title, footerLeft, footerMid, footerRight, t
draw
=
ImageDraw
.
Draw
(
image
)
font
=
ImageFont
.
truetype
(
textfont
,
fontsize
)
font
=
get_font
(
fontsize
)
padding
=
10
_
,
_
,
w
,
h
=
draw
.
textbbox
((
0
,
0
),
title
,
font
=
font
)
fontsize
=
min
(
int
(
fontsize
*
(((
image
.
size
[
0
]
*
0.75
)
-
(
padding
*
4
))
/
w
)),
72
)
font
=
ImageFont
.
truetype
(
textfont
,
fontsize
)
font
=
get_font
(
fontsize
)
_
,
_
,
w
,
h
=
draw
.
textbbox
((
0
,
0
),
title
,
font
=
font
)
draw
.
text
((
padding
,
padding
),
title
,
anchor
=
'lt'
,
font
=
font
,
fill
=
(
255
,
255
,
255
,
230
))
...
...
@@ -163,7 +168,7 @@ def caption_image_overlay(srcimage, title, footerLeft, footerMid, footerRight, t
_
,
_
,
w
,
h
=
draw
.
textbbox
((
0
,
0
),
footerRight
,
font
=
font
)
fontsize_right
=
min
(
int
(
fontsize
*
(((
image
.
size
[
0
]
/
3
)
-
(
padding
))
/
w
)),
72
)
font
=
ImageFont
.
truetype
(
textfont
,
min
(
fontsize_left
,
fontsize_mid
,
fontsize_right
))
font
=
get_font
(
min
(
fontsize_left
,
fontsize_mid
,
fontsize_right
))
draw
.
text
((
padding
,
image
.
size
[
1
]
-
padding
),
footerLeft
,
anchor
=
'ls'
,
font
=
font
,
fill
=
(
255
,
255
,
255
,
230
))
draw
.
text
((
image
.
size
[
0
]
/
2
,
image
.
size
[
1
]
-
padding
),
footerMid
,
anchor
=
'ms'
,
font
=
font
,
fill
=
(
255
,
255
,
255
,
230
))
...
...
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