Image Resizing and Cropping
Making an image bigger, cropping it to a square... these are simple tasks, but they matter a lot in image generation.
- The model's ideal resolution: Every model has a resolution where it performs best.
- Saving VRAM: Accidentally load and process a 4K image, and you'll hit "Out of memory" in no time.
- Matching your inputs: For things like compositing, you need several images to be the same size.
You'll do this a lot, so it's worth getting a solid grasp of how each node differs.
Getting Image Information
Get Image Size Node
Outputs the image's width, height, and batch size (number of images) as numbers.

Resize
Resize Image/Mask Node
A node that lets you switch between several resize methods.
This one node covers most of what you'll need. (It can resize masks too, by the way.)

scale total pixels
Resizes to the specified total pixel count while keeping the aspect ratio.
Calculated as 1024 * 1024 = 1.00MP.
| Target Size | Total Pixels | Setting Value |
|---|---|---|
| 512 × 512 | 262,144 | 0.25 |
| 768 × 768 | 589,824 | 0.56 |
| 1024 × 1024 | 1,048,576 | 1.00 |
| 1536 × 1536 | 2,359,296 | 2.25 |

match size
Resizes the image to the same size as a reference image.
You used to have to get the reference image's size and pass it to another node, but now it all happens in one.
match: Connect the image you want to use as a reference.cropdisabled: Distorts the image if the aspect ratio is different.center: Keeps the center and crops off (discards) whatever sticks out.

scale to multiple
Resizes so that width and height are multiples of N.
I go into detail in Why can I only generate resolutions that are multiples of 8?, but because of how the VAE works, diffusion models can't handle resolutions that aren't a certain multiple as-is.
Some node along the way often adjusts this for you, but this comes in handy when you get errors unless the resolution is exactly right, or when you want the input and output pixels to match exactly.
ImageScaleToMaxDimension Node
Resizes so that the image's long side matches the size you set, keeping the aspect ratio.
(For example, the longer side becomes 1024px whether the image is portrait or landscape.)

Padding
Padding adjusts the size by adding margins (such as black bars) around the image.
Some nodes can output the margin as a mask, which makes padding a common first step for Outpainting.
ResizeAndPadImage Node
Resizes to the specified resolution and fills the rest with padding.

This node can't output the padding as a mask, so you'll hardly ever use it.
Pad Image for Outpainting Node
Adds the specified number of pixels of margin to the top, bottom, left, and right of the image.

The margin is output as a mask.
- feathering: Blurs the boundary between the margin and the image. Affects only the mask.
Cropping and Other Edits
ImageCrop Node
Cuts out a rectangular part of the image, given x/y coordinates and a width and height.

ImageRotate Node
Rotates the image by 90 / 180 / 270 degrees.

ImageFlip Node
Flips the image horizontally / vertically.

Resize Image v2 Node
This node comes from kijai/ComfyUI-KJNodes.
It's basically the resize, crop, and padding above rolled into one node.
| Parameter Name | Description |
|---|---|
| width / height | Target width and height (no change if 0) |
| upscale_method | Interpolation method during resizing (nearest, bilinear, etc.) |
| keep_proportion | stretch, pad, crop, etc. |
| pad_color | Color for padding (RGB) |
| crop_position | center, top, bottom, left, right |
| divisible_by | Resizes to a resolution that is a multiple of this value (e.g., 32, 64) |
I used to use this a lot for resizing to multiples of N, but core nodes can do that now, so I don't use it much anymore.
Putting It Together
Let's combine the nodes so far to do something a little more involved.
Crop Image to Half

- Get the size of the image
- Calculate half the width with the
Simple mathnode - Feed that width into the
ImageCropnode to crop the image in half



