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
e8f34e3b
Commit
e8f34e3b
authored
Mar 27, 2023
by
AUTOMATIC1111
Committed by
GitHub
Mar 27, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8938 from space-nuko/fix-image-ar-overlay
Fix img2img aspect ratio overlay in Gradio 3.23.0
parents
c19036d3
945f6e5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
23 deletions
+37
-23
javascript/aspectRatioOverlay.js
javascript/aspectRatioOverlay.js
+26
-23
style.css
style.css
+11
-0
No files found.
javascript/aspectRatioOverlay.js
View file @
e8f34e3b
...
@@ -12,7 +12,7 @@ function dimensionChange(e, is_width, is_height){
...
@@ -12,7 +12,7 @@ function dimensionChange(e, is_width, is_height){
currentHeight
=
e
.
target
.
value
*
1.0
currentHeight
=
e
.
target
.
value
*
1.0
}
}
var
inImg2img
=
Boolean
(
gradioApp
().
querySelector
(
"
button.rounded-t-lg.border-gray-200
"
))
var
inImg2img
=
gradioApp
().
querySelector
(
"
#tab_img2img
"
).
style
.
display
==
"
block
"
;
if
(
!
inImg2img
){
if
(
!
inImg2img
){
return
;
return
;
...
@@ -22,7 +22,7 @@ function dimensionChange(e, is_width, is_height){
...
@@ -22,7 +22,7 @@ function dimensionChange(e, is_width, is_height){
var
tabIndex
=
get_tab_index
(
'
mode_img2img
'
)
var
tabIndex
=
get_tab_index
(
'
mode_img2img
'
)
if
(
tabIndex
==
0
){
// img2img
if
(
tabIndex
==
0
){
// img2img
targetElement
=
gradioApp
().
querySelector
(
'
div[data-testid=image] img
'
);
targetElement
=
gradioApp
().
querySelector
(
'
#img2img_image
div[data-testid=image] img
'
);
}
else
if
(
tabIndex
==
1
){
//Sketch
}
else
if
(
tabIndex
==
1
){
//Sketch
targetElement
=
gradioApp
().
querySelector
(
'
#img2img_sketch div[data-testid=image] img
'
);
targetElement
=
gradioApp
().
querySelector
(
'
#img2img_sketch div[data-testid=image] img
'
);
}
else
if
(
tabIndex
==
2
){
// Inpaint
}
else
if
(
tabIndex
==
2
){
// Inpaint
...
@@ -30,7 +30,7 @@ function dimensionChange(e, is_width, is_height){
...
@@ -30,7 +30,7 @@ function dimensionChange(e, is_width, is_height){
}
else
if
(
tabIndex
==
3
){
// Inpaint sketch
}
else
if
(
tabIndex
==
3
){
// Inpaint sketch
targetElement
=
gradioApp
().
querySelector
(
'
#inpaint_sketch div[data-testid=image] img
'
);
targetElement
=
gradioApp
().
querySelector
(
'
#inpaint_sketch div[data-testid=image] img
'
);
}
}
if
(
targetElement
){
if
(
targetElement
){
...
@@ -38,7 +38,7 @@ function dimensionChange(e, is_width, is_height){
...
@@ -38,7 +38,7 @@ function dimensionChange(e, is_width, is_height){
if
(
!
arPreviewRect
){
if
(
!
arPreviewRect
){
arPreviewRect
=
document
.
createElement
(
'
div
'
)
arPreviewRect
=
document
.
createElement
(
'
div
'
)
arPreviewRect
.
id
=
"
imageARPreview
"
;
arPreviewRect
.
id
=
"
imageARPreview
"
;
gradioApp
().
getRootNode
().
appendChild
(
arPreviewRect
)
gradioApp
().
appendChild
(
arPreviewRect
)
}
}
...
@@ -91,23 +91,26 @@ onUiUpdate(function(){
...
@@ -91,23 +91,26 @@ onUiUpdate(function(){
if
(
arPreviewRect
){
if
(
arPreviewRect
){
arPreviewRect
.
style
.
display
=
'
none
'
;
arPreviewRect
.
style
.
display
=
'
none
'
;
}
}
var
inImg2img
=
Boolean
(
gradioApp
().
querySelector
(
"
button.rounded-t-lg.border-gray-200
"
))
var
tabImg2img
=
gradioApp
().
querySelector
(
"
#tab_img2img
"
);
if
(
inImg2img
){
if
(
tabImg2img
)
{
let
inputs
=
gradioApp
().
querySelectorAll
(
'
input
'
);
var
inImg2img
=
tabImg2img
.
style
.
display
==
"
block
"
;
inputs
.
forEach
(
function
(
e
){
if
(
inImg2img
){
var
is_width
=
e
.
parentElement
.
id
==
"
img2img_width
"
let
inputs
=
gradioApp
().
querySelectorAll
(
'
input
'
);
var
is_height
=
e
.
parentElement
.
id
==
"
img2img_height
"
inputs
.
forEach
(
function
(
e
){
var
is_width
=
e
.
parentElement
.
id
==
"
img2img_width
"
if
((
is_width
||
is_height
)
&&
!
e
.
classList
.
contains
(
'
scrollwatch
'
)){
var
is_height
=
e
.
parentElement
.
id
==
"
img2img_height
"
e
.
addEventListener
(
'
input
'
,
function
(
e
){
dimensionChange
(
e
,
is_width
,
is_height
)}
)
e
.
classList
.
add
(
'
scrollwatch
'
)
if
((
is_width
||
is_height
)
&&
!
e
.
classList
.
contains
(
'
scrollwatch
'
)){
}
e
.
addEventListener
(
'
input
'
,
function
(
e
){
dimensionChange
(
e
,
is_width
,
is_height
)}
)
if
(
is_width
){
e
.
classList
.
add
(
'
scrollwatch
'
)
currentWidth
=
e
.
value
*
1.0
}
}
if
(
is_width
){
if
(
is_height
){
currentWidth
=
e
.
value
*
1.0
currentHeight
=
e
.
value
*
1.0
}
}
if
(
is_height
){
})
currentHeight
=
e
.
value
*
1.0
}
}
})
}
}
});
});
style.css
View file @
e8f34e3b
...
@@ -520,6 +520,17 @@ div.dimensions-tools{
...
@@ -520,6 +520,17 @@ div.dimensions-tools{
background-color
:
rgba
(
0
,
0
,
0
,
0.8
);
background-color
:
rgba
(
0
,
0
,
0
,
0.8
);
}
}
#imageARPreview
{
position
:
absolute
;
top
:
0px
;
left
:
0px
;
border
:
2px
solid
red
;
background
:
rgba
(
255
,
0
,
0
,
0.3
);
z-index
:
900
;
pointer-events
:
none
;
display
:
none
;
}
/* context menu (ie for the generate button) */
/* context menu (ie for the generate button) */
#context-menu
{
#context-menu
{
...
...
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