mcmonkeyprojects / SwarmUI

SwarmUI (formerly StableSwarmUI), A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility.
MIT License
1.33k stars 96 forks source link

Use dimensions of selected image when doing img2img #92

Open Dwedit opened 3 months ago

Dwedit commented 3 months ago

Feature Idea

If you are doing an img2img, you probably want to output to be the size of the image you selected rather than the default size. I'd request a checkbox for 'use selected image dimensions'.

Yes, you can currently manually type in the image dimensions somewhere else on the page. It's a pain to do that.

Other

No response

Dwedit commented 2 months ago

A solution to this issue would require not only providing the coordinates, but also adding support for coordinates that are not multiples of 8.

There is a comfy UI extension called comfyui-image-round which provides a Padding node and a Cropping node. The Padding node pads the image to a multiple of 8 (or any other desired number), and the Cropping node will crop the image. You can also connect the Cropping node to the Padding node, and it will undo the padding added to the image.

When the base image is already a multiple of 8, no cropping or padding is required. But if it's not, you need padding and cropping to match the exact resolution of the input image. Using comfy nodes to do this is the most direct way.

A potential problem is that the padding node wants to pad with a single solid color. I don't know if that is the best idea or not. An alternative could be to pad the image with a flipped version of the image. I don't know which will produce less artifacts when it goes through a VAE encoder.