From 572b0329cf64e24b88513b1e51f2e00a4c030afe Mon Sep 17 00:00:00 2001 From: Gary Wolfe Date: Mon, 23 Dec 2024 21:46:25 -0500 Subject: [PATCH] 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) {