Merge pull request #303 from madrang/resize-inpainting-disable

Resize in-painting disable
This commit is contained in:
cmdr2 2022-10-08 19:48:43 +05:30 committed by GitHub
commit d93f3468d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,6 +269,9 @@ async function healthCheck() {
} }
} }
function resizeInpaintingEditor() { function resizeInpaintingEditor() {
if (!maskSetting.checked) {
return
}
let widthValue = parseInt(widthField.value) let widthValue = parseInt(widthField.value)
let heightValue = parseInt(heightField.value) let heightValue = parseInt(heightField.value)
if (widthValue === heightValue) { if (widthValue === heightValue) {
@ -281,6 +284,11 @@ function resizeInpaintingEditor() {
widthValue = (widthValue / heightValue) * INPAINTING_EDITOR_SIZE widthValue = (widthValue / heightValue) * INPAINTING_EDITOR_SIZE
heightValue = INPAINTING_EDITOR_SIZE heightValue = INPAINTING_EDITOR_SIZE
} }
if (inpaintingEditor.opts.aspectRatio === (widthValue / heightValue).toFixed(3)) {
// Same ratio, don't reset the canvas.
return
}
inpaintingEditor.opts.aspectRatio = (widthValue / heightValue).toFixed(3)
inpaintingEditorContainer.style.width = widthValue + 'px' inpaintingEditorContainer.style.width = widthValue + 'px'
inpaintingEditorContainer.style.height = heightValue + 'px' inpaintingEditorContainer.style.height = heightValue + 'px'
@ -1145,6 +1153,7 @@ initImageClearBtn.addEventListener('click', function() {
maskSetting.addEventListener('click', function() { maskSetting.addEventListener('click', function() {
inpaintingEditorContainer.style.display = (this.checked ? 'block' : 'none') inpaintingEditorContainer.style.display = (this.checked ? 'block' : 'none')
resizeInpaintingEditor()
}) })
promptsFromFileBtn.addEventListener('click', function() { promptsFromFileBtn.addEventListener('click', function() {