From c19b9f48b4225356ce19df241b24184970819c35 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Wed, 15 Feb 2023 00:03:16 -0300 Subject: [PATCH] fixes https://github.com/zero01101/openOutpaint-webUI-extension/issues/34 Signed-off-by: Victor Seiji Hariki --- js/webui.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/webui.js b/js/webui.js index 64a3d69..fde3be1 100644 --- a/js/webui.js +++ b/js/webui.js @@ -118,6 +118,19 @@ data.image.resourceName || "External Resource", image ); + // Fit image on screen if too big + const wr = image.width / window.innerWidth; + const hr = image.height / window.innerHeight; + const mr = Math.max(wr, hr); + + if (mr > viewport.zoom) { + viewport.zoom = mr * 1.3; + viewport.transform(imageCollection.element); + + toolbar._current_tool.redrawui && + toolbar._current_tool.redrawui(); + } + tools.stamp.enable(); }; }