From 8cd6ca626943e5d3e67c448a0326e1a126da2a9c Mon Sep 17 00:00:00 2001 From: Gary Wolfe Date: Sun, 22 Dec 2024 17:36:01 -0500 Subject: [PATCH 1/5] Remove inpaint size limit With the limit removed, inpaint can work with image sizes larger than 768 pixels. --- ui/media/js/image-editor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/media/js/image-editor.js b/ui/media/js/image-editor.js index dac172fd..77dceefa 100644 --- a/ui/media/js/image-editor.js +++ b/ui/media/js/image-editor.js @@ -559,12 +559,12 @@ class ImageEditor { } if (width > height) { - var max_size = Math.min(parseInt(window.innerWidth * 0.9), width, 768) + var max_size = Math.min(parseInt(window.innerWidth * 0.9), width) var multiplier = max_size / width width = (multiplier * width).toFixed() height = (multiplier * height).toFixed() } else { - var max_size = Math.min(parseInt(window.innerHeight * 0.9), height, 768) + var max_size = Math.min(parseInt(window.innerHeight * 0.9), height) var multiplier = max_size / height width = (multiplier * width).toFixed() height = (multiplier * height).toFixed() From 33ca04b9163c670f9a5455b41bb75f4e0531bf3a Mon Sep 17 00:00:00 2001 From: Gary Wolfe Date: Sun, 22 Dec 2024 21:22:37 -0500 Subject: [PATCH 2/5] Use as Input sets size Force the generate size to match the image size when clicking Use as Input. --- ui/media/js/main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index e59a6ace..9e288473 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -623,6 +623,11 @@ function onUseAsInputClick(req, img) { initImagePreview.src = imgData maskSetting.checked = false + + //Force the image settings size to match the input, as inpaint currently only works correctly + //if input image and generate sizes match. + widthField.value = img.naturalWidth; + heightField.value = img.naturalHeight; } function onUseForControlnetClick(req, img) { From 572b0329cf64e24b88513b1e51f2e00a4c030afe Mon Sep 17 00:00:00 2001 From: Gary Wolfe Date: Mon, 23 Dec 2024 21:46:25 -0500 Subject: [PATCH 3/5] Prevent invalid size settings for Use As Input Images larger than the window size show up as blank sizes when setting the field. Retain previous (presumably valid) size rather than set an invalid one. --- ui/media/js/main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 9e288473..e360ac1a 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -626,8 +626,15 @@ function onUseAsInputClick(req, img) { //Force the image settings size to match the input, as inpaint currently only works correctly //if input image and generate sizes match. + var tempWidth = widthField.value; + var tempHeight = heightField.value; widthField.value = img.naturalWidth; heightField.value = img.naturalHeight; + //If it's unhappy with the new values, restore the original values. + if (widthField.value=="" || heightField.value=="") { + widthField.value = tempWidth; + heightField.value = tempHeight; + } } function onUseForControlnetClick(req, img) { From ad06e345c940d737a38664de7b351731eb1ab7f0 Mon Sep 17 00:00:00 2001 From: Gary Wolfe Date: Tue, 24 Dec 2024 23:36:12 -0500 Subject: [PATCH 4/5] Allow new resolutions with Use As Input When Use As Input provides unlisted resolutions, add them first so that they'll be recognized as valid. --- ui/media/js/main.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index e360ac1a..755bca2f 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -626,15 +626,10 @@ function onUseAsInputClick(req, img) { //Force the image settings size to match the input, as inpaint currently only works correctly //if input image and generate sizes match. - var tempWidth = widthField.value; - var tempHeight = heightField.value; + addImageSizeOption(img.naturalWidth); + addImageSizeOption(img.naturalHeight); widthField.value = img.naturalWidth; heightField.value = img.naturalHeight; - //If it's unhappy with the new values, restore the original values. - if (widthField.value=="" || heightField.value=="") { - widthField.value = tempWidth; - heightField.value = tempHeight; - } } function onUseForControlnetClick(req, img) { From e084a35ffc1b11cb028d1455eee881921938f6cf Mon Sep 17 00:00:00 2001 From: Gary Wolfe Date: Fri, 27 Dec 2024 22:10:14 -0500 Subject: [PATCH 5/5] Allow image editor to grow Limiting the editor size seems to cause failures in inpainting, probably due to a mismatch with the requested image size. --- ui/media/js/image-editor.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/media/js/image-editor.js b/ui/media/js/image-editor.js index 77dceefa..8727cbf9 100644 --- a/ui/media/js/image-editor.js +++ b/ui/media/js/image-editor.js @@ -557,14 +557,17 @@ class ImageEditor { if (width == this.width && height == this.height) { return } - + //The below code tries to limit the size of the image to fit within the editor window. + //However, at this time, this causes problems with a mis-match between the mask size and + //the requested image size. For now, allow the drawing/inpaint window to be as large + //as necessary. if (width > height) { - var max_size = Math.min(parseInt(window.innerWidth * 0.9), width) + var max_size = width; //Math.min(parseInt(window.innerWidth * 0.9), width) var multiplier = max_size / width width = (multiplier * width).toFixed() height = (multiplier * height).toFixed() } else { - var max_size = Math.min(parseInt(window.innerHeight * 0.9), height) + var max_size = height; //Math.min(parseInt(window.innerHeight * 0.9), height) var multiplier = max_size / height width = (multiplier * width).toFixed() height = (multiplier * height).toFixed()