From 3478ee268f10b573fb0fb5d019584aeabc06735b Mon Sep 17 00:00:00 2001 From: DualFroz Date: Fri, 11 Sep 2026 23:05:54 +0200 Subject: [PATCH] Keep the requested image size when restoring a task with a ControlNet image The control image load handler resizes the output to the control image, and it fires after restoreTaskToUI() has applied the task settings, so 'Use these settings' always fell back to the control image size. --- ui/media/js/dnd.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui/media/js/dnd.js b/ui/media/js/dnd.js index 0d375a2..1978c0b 100644 --- a/ui/media/js/dnd.js +++ b/ui/media/js/dnd.js @@ -608,6 +608,21 @@ function restoreTaskToUI(task, fieldsToSkip) { // hide source image controlImageClearBtn.dispatchEvent(new Event("click")) } else if (task.reqBody.control_image !== undefined) { + if (controlImagePreview.src !== task.reqBody.control_image) { + // the control image load handler resizes the output to the control image, so re-apply + // the size of the task once it has fired + controlImagePreview.addEventListener( + "load", + function () { + for (const key of ["width", "height"]) { + if (key in task.reqBody && !fieldsToSkip.includes(key)) { + TASK_MAPPING[key].setUI(task.reqBody[key]) + } + } + }, + { once: true } + ) + } // listen for inpainter loading event, which happens AFTER the main image loads (which reloads the inpai controlImagePreview.src = task.reqBody.control_image }