| /** | |
| * temporary fix for https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/668 | |
| * @see https://github.com/gradio-app/gradio/issues/1721 | |
| */ | |
| function imageMaskResize() { | |
| const allCanvas = gradioApp().querySelectorAll("#img2maskimg .touch-none canvas"); | |
| if (!allCanvas.length) { | |
| window.removeEventListener("resize", imageMaskResize); | |
| return; | |
| } | |
| const wrapper = allCanvas[0].closest(".touch-none"); | |
| const previewImage = wrapper.previousElementSibling; | |
| if (!previewImage.complete) { | |
| previewImage.addEventListener("load", imageMaskResize); | |
| return; | |
| } | |
| const w = previewImage.width; | |
| const h = previewImage.height; | |
| const nw = previewImage.naturalWidth; | |
| const nh = previewImage.naturalHeight; | |
| const portrait = nh > nw; | |
| const wW = Math.min(w, portrait ? (h / nh) * nw : (w / nw) * nw); | |
| const wH = Math.min(h, portrait ? (h / nh) * nh : (w / nw) * nh); | |
| wrapper.style.width = `${wW}px`; | |
| wrapper.style.height = `${wH}px`; | |
| wrapper.style.left = `0px`; | |
| wrapper.style.top = `0px`; | |
| allCanvas.forEach((c) => { | |
| c.style.width = c.style.height = ""; | |
| c.style.maxWidth = "100%"; | |
| c.style.maxHeight = "100%"; | |
| c.style.objectFit = "contain"; | |
| }); | |
| } | |
| onAfterUiUpdate(imageMaskResize); | |
| window.addEventListener("resize", imageMaskResize); | |
Xet Storage Details
- Size:
- 1.37 kB
- Xet hash:
- 63a94258f4a0cf63f0ad1b8ca27ca4b7b5536bd23ec938c7a612bb2c6420a4b7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.