Nodes:Fit Size From Int/Image/Resize, Load Image And Resize To Fit, Pick Image From Batch/List, Crop Image Into Even Pieces, Image Region To Mask... A simple set of nodes for making an image fit within a bounding box
A simple set of nodes for making an image fit within a bounding box
To install this node, open your custom_nodes
folder in a terminal and clone this project into it.
git clone https://github.com/bronkula/comfyui-fitsize.git
There are currently a few different nodes that are all based around fitting content within a bounding box. The reasoning behind this is that I like to copy screengrab content into comfyui, and I don't want to worry about what size or aspect ratio it is. I want it to automatically be fit to something appropriate.
These nodes will automatically fudge the sizes to fit within increments of 8, so that the output image sizes will be more palatable to Stable Diffusion. They should all be able to upscale or downscale whatever input they're given.
This node is the most basic. It's the basic math of fitting some content within a bounding box. Give it a width, height, and max size, and it will scale the sizes to fit in the max size.
Obviously you can also change the inputs to accept values from outside.
This node accepts any image input and will extract the width and height automatically. All of these nodes can be told to upscale or not. The normal use of these nodes is to reduce a size down to something reasonable, but if upscale is true than it will also try to increase the size to the max_size.
Now this is where things get interesting. This node accepts a vae so that we can skip right to outputting a rescaled image. It will output both an image and a latent batch. This makes it a very useful tool for img2img workflows.
Because the node now outputs a latent batch based on the original image, img2img workflows are much easier. Simply reduce the denoise in the ksampler to somewhere around 0.5
. Anything less will be more like the original image, and anything more will start to deviate wildly. Noise can be added to the image itself for further iteration.
But I decided that I wanted to just add in the image handling completely into one node, so that's what this one is. It has built in image handling compeletely. You can copy and paste image data directly into it, just like the default comfyui node. You don't have to save an image, just paste it in.
This workflow uses a number of other custom node sets to showcase that this node works great in the middle of a workflow.
Here is a simpler workflow example using the Efficiency nodes. The Fit nodes should fit right into the middle of a lot of other workflows.
This node will pick one image or even a couple from a batch of images
This node will pick one or a couple images from a list of batches
This node will cut an image into multiple pieces of rows and columns
This node will turn out a region from an image based on rows and columns
[lanczos,nearest,bilinear,bicubic]
Hamilton Cline https://hdraws.com