ComfyUI
ComfyUI copied to clipboard
VAE Simple Resize instead of cropping
Currently ComfyUI crops out of aspect images, couldn't we just resize width/height to nearest multiple of 8? It would be awesome to have a mode, to either crop or resize.
In a artistic environment it doesn't seem appropriate to be altering anyone's images without it being an explicit process by the user to begin with. If it is to crop, it probably should do it by cropping into the center of the image, too, not from 0,0
I can diffuse arbitrary sized images in Diffusers so long as they're multiples of 8, and that allows me to do compositing by simply resizing back to source size, but in ComfyUI I can't do that because it badly crops images (see below)

My node is already outputting a image that is resized to a multiple of 64, the image is 320x512 which is then cropped and resized to 256x448, which doesn't seem necessary.
yeah this behaviour is going to go once I implement some way to have to sampling "work" with any latent resolution.
yeah this behaviour is going to go once I implement some way to have to sampling "work" with any latent resolution.
Could you point me in the direction of the calculations for cropping? Maybe I can compensate for it in the meantime with the nodes output.
https://github.com/comfyanonymous/ComfyUI/blob/master/nodes.py#L130
If you pass images with the width and height that are multiples of 64 it won't crop them.
Hmm it still seems to be cropping them. I am resizing to a multiple of 64 (was 8 but I don't think SD can actually do anything below 64 even if it's crap results).
The image above 320x512 is a multiple of 64
This should be much less of a problem now: https://github.com/comfyanonymous/ComfyUI/commit/ba8a4c3667eda95649d8bfa906186d42e9ac6835
It still crops them a bit if the resolution isn't a multiple of 8 but it should be much less noticeable.
Why not create a toggle mode crop-area (proportional) and constrain, where constrain is not proportional and just forces a multiple. For say, a slight variance, say 8-28 pixels, this will also not be very noticeable when constrained and not proportional, but will preserve it's boundaries for operations that nodes may use.
Yes please for 'constrain' been trying in vain to resize a square open pose image on top of a blank landscape image. I only seem to be able to squash it or crop it at the moment... been through and tried nearly all nodes and settings I think...
I just managed to find something that works perfectly here: https://github.com/BadCafeCode/masquerade-nodes-comfyui The 'Paste By Mask' node has a keep_ratio_fit option, so I just generate a black image the same size as my latent, a white image, also the same size (as we need an all white mask) then use the blank image as target and the open pose image as source, and it shrinks it to fit nicely.
(Just one other thing - you also need the Masquerade node Change Channel Count to convert it from RGBA to RGB otherwise sampler throws an error about number of channels)