Image Resizing and Cropping
It may seem like a simple task of enlarging an image or cropping it to a square, but it is a very important process in image generation.
- Model's Optimal Resolution: Models have a "resolution where they perform best".
- Saving VRAM: If you inadvertently load and process a 4K image, you will instantly run "Out of memory".
- Unifying Materials: In image compositing, etc., it is necessary to align the sizes of multiple materials.
Since this is a frequently used task, let's firmly understand the differences between each node.
Getting Image Information
Get Image Size Node
Outputs the width, height, and batch size (count) of the image as numerical values.

Resize
Resize Image/Mask Node
A node that allows you to switch between several resizing methods.
Basically, this one node covers most of the necessary processing. (By the way, masks can also be resized.)

scale total pixels
Resizes the image to match the specified total number of pixels while maintaining 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 match the size of a reference image.
Previously, it was necessary to get the size of the reference image and pass it to another node, but now this combines it into one.
match: Connect the image you want to use as a reference.cropdisabled: Distorts the image if the aspect ratio is different.center: Maintains the center and crops (discards) the protruding parts.

scale to multiple
Resizes the vertical and horizontal dimensions to be multiples of N.
Details are explained in Why can I only generate resolutions that are multiples of 8?, but in short, diffusion models cannot handle resolutions that are not specific multiples due to VAE limitations.
Basically, ComfyUI often adjusts automatically internally, so there isn't much need for this node unless you encounter errors with non-specific resolutions, or when you want to "perfectly match" the pixels of the input and output.
ImageScaleToMaxDimension Node
Resizes the image so that the long side becomes the set size, maintaining the aspect ratio.
(Example: Whether it is a portrait or landscape image, make the longer side 1024px)

Padding
Padding is the process of adjusting the size by adding margins (black bars, etc.) around the image.
Depending on the node, this margin part can be output as a mask, so it is used as preparation for Outpainting.
ResizeAndPadImage Node
Resizes to the specified resolution and fills the missing parts with padding.

Since this node cannot output the padding part as a mask, there are practically no occasions to use it.
Pad Image for Outpainting Node
Adds margins of the specified number of pixels to the top, bottom, left, and right of the image.

The margin part is output as a mask.
- feathering: Blurs the boundary between the margin and the image. Affects only the mask.
Crop and Other Edit Operations
ImageCrop Node
Crops a part of the image in a rectangle by specifying x, y coordinates and width/height.

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

ImageFlip Node
Flips the image horizontally / vertically.

Resize Image v2 Node
This is a node included in kijai/ComfyUI-KJNodes.
It is like a node that combines the above resize, crop, and padding into one.
| 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) |
Previously, this was used frequently to resize to multiples of N, but now that core nodes handle this, it is not used much.
A Little Application
Let's try some slightly complex image processing by combining the nodes so far.
Crop Image to Half

- Get the size of the image
- Calculate half the width with
Simple mathnode - Input the calculated width to
ImageCropnode and crop to half



