From d667fc435f6210575ba50a6f3a05d3853b233caa Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Tue, 28 Mar 2023 22:23:40 +0300 Subject: add "resize by" and "resize to" tabs to img2img --- javascript/ui.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'javascript/ui.js') diff --git a/javascript/ui.js b/javascript/ui.js index 4a440193..dc538231 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -361,3 +361,8 @@ function selectCheckpoint(name){ desiredCheckpointName = name; gradioApp().getElementById('change_checkpoint').click() } + +function currentImg2imgSourceResolution(_, _, scaleBy){ + var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img') + return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy] +} -- cgit v1.2.3 From e40b2d947d874ed5504701bfd8e32243e0c456eb Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sat, 29 Apr 2023 19:39:22 +0300 Subject: change gradio callback from change to release in a bunch of places now that it's fixed in gradio --- javascript/ui.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'javascript/ui.js') diff --git a/javascript/ui.js b/javascript/ui.js index dc538231..0ba92ef8 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -366,3 +366,14 @@ function currentImg2imgSourceResolution(_, _, scaleBy){ var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img') return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy] } + +function updateImg2imgResizeToTextAfterChangingImage(){ + // At the time this is called from gradio, the image has no yet been replaced. + // There may be a better solution, but this is simple and straightforward so I'm going with it. + + setTimeout(function() { + gradioApp().getElementById('img2img_update_resize_to').click() + }, 500); + + return [] +} -- cgit v1.2.3