Skip to content
,

How to Resize, Crop and Pad Images in ComfyUI (Every Node)

7–10 minutes
Woman in a server room holding a tablet with a RESIZE card, hook resize any image

Resizing sounds trivial until a workflow breaks because an image is 1023 pixels wide, a ControlNet map doesn’t match the latent, or a phone photo is so big that VAE Encode runs out of memory.

ComfyUI has more than half a dozen built-in nodes for resizing, cropping and padding, and each one fits a different job.

This guide explains every core resize, crop and pad node, checked against the ComfyUI source. You’ll see which node to use for exact sizes, aspect-ratio-safe resizing, megapixel targets, model-friendly multiples of 8 or 64, and outpainting canvases.

TL;DR

  • Exact size: Upscale Image (width, height, crop center). Set width or height to 0 to keep the aspect ratio.
  • By a factor: Upscale Image By (scale_by 0.01 to 8.0).
  • Model-friendly size from any photo: Scale Image to Total Pixels at 1.0 megapixels, with resolution_steps 8 or 64.
  • Everything in one node: Resize Image/Mask (by dimensions, multiplier, longer/shorter side, megapixels, match another image, or “scale to multiple”).
  • Methods: area for shrinking, lanczos for enlarging, nearest-exact for pixel art.

New to ComfyUI? My ComfyUI guide covers installing and your first workflow.

Which Resize Node Should You Use?

You want to… Use this node
Hit an exact size like 1024×1024 Upscale Image (crop: center)
Make an image 2x bigger or half the size Upscale Image By
Fit any photo to a model’s pixel budget Scale Image to Total Pixels
Make the longest side 1024 Scale Image to Max Dimension, or Resize Image/Mask
Match one image’s size to another Resize Image/Mask (match size)
Fix sizes not divisible by 8 or 64 Resize Image/Mask (scale to multiple)
Fit an image into a frame without cropping Resize And Pad Image
Add canvas for outpainting Pad Image for Outpainting
Add real detail when enlarging Upscale Image (using Model), not a plain resize

Plain resizing only stretches pixels. To add detail when you make an image bigger, use an upscale model as shown in my ComfyUI upscale guide.

Resize Methods: area, lanczos, bicubic and More

Most resize nodes ask for an upscale_method. The core image options are nearest-exact, bilinear, area, bicubic and lanczos. ComfyUI’s own tooltip on Resize Image/Mask gives the short version: area for downscaling, lanczos for upscaling, nearest-exact for pixel art.

Method Best for Notes
area Shrinking Averages pixels, so no jagged edges or shimmer
lanczos Enlarging Sharpest classic method; can add slight halos on hard edges
bicubic General use Smooth and a bit softer than lanczos
bilinear Masks and quick previews Soft, fast
nearest-exact Pixel art, hard masks No blending; keeps pixels crisp and blocky

Upscale Image: Exact Width and Height

Despite the name, Upscale Image shrinks too. It’s ComfyUI’s basic resize node.

  • width and height: default 512 each.
  • crop: disabled stretches the image to the new size; center crops the edges so the aspect ratio stays correct.
  • Set one of width or height to 0 and the source code calculates the other from the aspect ratio. Set both to 0 and the image passes through unchanged.

For a square 1024×1024 from a landscape photo, use width 1024, height 1024, crop center. For “1024 wide, whatever height”, use width 1024, height 0.

Upscale Image By: Scale by a Factor

Upscale Image By multiplies both sides by scale_by (default 1.0, range 0.01 to 8.0). Use 0.5 to halve an image, or 0.5 after a 4x upscale model to get a clean 2x. It always keeps the aspect ratio.

Scale Image to Total Pixels

This is the most useful node for photos of unknown size. It resizes the image so its total area equals the megapixels setting (default 1.0, which is about 1024×1024), keeping the aspect ratio.

The advanced resolution_steps input (default 1) rounds both sides to a multiple of that number. Set it to 8 for SD-family models or 16-64 for newer ones, so the result always fits the latent grid.

Use it before VAE Encode in img2img, editing and inpainting workflows. A 12-megapixel phone photo becomes a model-friendly ~1 MP image, and VAE Encode no longer runs out of memory. See my img2img guide for the full workflow.

Resize Image/Mask: The All-in-One Node

Newer ComfyUI versions include Resize Image/Mask. It accepts an image or a mask and outputs the same type. A resize type dropdown switches its settings:

Resize type Settings Use it for
scale dimensions width, height (0 = auto), crop disabled/center Exact sizes
scale by multiplier multiplier 0.01-8.0 2x, 0.5x
scale longer dimension longer_size “Longest side 1024”
scale shorter dimension shorter_size “Shortest side 768”
scale width / scale height width or height Fix one side, keep the ratio
scale total pixels megapixels Model pixel budgets
match size match (an image or mask) Make a mask or ControlNet map match an image
scale to multiple multiple (default 8) Make sides divisible by 8, 16 or 64

Its scale method defaults to area. Because it handles masks too, it’s the easiest way to keep a mask and its image the same size. That avoids the size mismatch errors covered in my ComfyUI masks guide.

Scale Image to Max Dimension

This node scales the image so its longest side equals largest_size (default 512), keeping the ratio. It’s the quickest way to say “no side bigger than 1536”.

Cropping Images

  • Crop Image: the current crop node, which uses a bounding-box widget (crop_region) to set the area.
  • Crop Image (DEPRECATED): the older version with number inputs: width, height (default 512) and x, y (default 0) for the top-left corner. Old workflows still load it.
  • Crop Image to Mask: crops around a mask and outputs a fixed size (default 1024×1024), with a pad_factor margin and grow_mask option. Handy for working on one face or object at a higher resolution.

To crop as part of a resize, Upscale Image and Resize Image/Mask with crop: center trim the edges evenly.

Padding: Resize And Pad, Pad Image

Resize And Pad Image

Fits the whole image inside target_width x target_height (default 512×512) without cropping, then fills the leftover space. Advanced options set padding_color (white or black) and interpolation. Use it when nothing in the picture may be cut off, such as a product shot going into a square model input.

Pad Image

Adds borders by exact pixels (left, top, right, bottom), by a multiplier, or up to a multiple (default 32). You choose a fill color and optional feathering. “Pad to a multiple” is a clean way to fix odd sizes without stretching.

Pad Image for Outpainting

Adds canvas and outputs a mask for the new area, ready for inpainting. Its feathering defaults to 40. The masks guide shows the outpainting setup.

Resizing Latents Instead of Images

Upscale Latent and Upscale Latent By resize the latent directly (methods nearest-exact, bilinear, area, bicubic, bislerp). It’s faster because there’s no decode and encode, but a resized latent looks blurry or noisy until you sample it again at denoise 0.5 or higher. That’s the classic latent hires fix, explained in my hires fix guide.

Good Sizes for Popular Models

Model Typical sizes Resize tip
SD 1.5 512×512, 512×768 Scale to total pixels 0.26-0.4 MP, steps 8
SDXL, Pony, Illustrious 1024×1024, 832×1216, 1216×832 1.0 MP, steps 64
Flux and similar About 1 MP, up to around 2 MP 1.0-2.0 MP, steps 16
Wan / video models 480p (832×480) or 720p (1280×720) Resize the start image to the exact video size

For SDXL sizes and settings, see my ComfyUI SDXL guide.

Troubleshooting

Size mismatch or “tensors must match” errors

Two inputs that must match (image and mask, image and ControlNet map) are different sizes. Use Resize Image/Mask with match size, or resize both with the same settings.

Faces look squashed or stretched

You used crop: disabled with a different aspect ratio. Switch to center, or set one side to 0.

Jagged edges or moiré after shrinking

Use area for downscaling. nearest-exact and bilinear alias fine patterns.

Out of memory at VAE Encode

The input image is too big. Put Scale Image to Total Pixels (1.0 MP) before VAE Encode. My ComfyUI VAE guide covers tiled encoding for large images.

Thin borders or odd crops in the result

The size wasn’t a multiple of 8 (or what the model needs). Round with resolution_steps or “scale to multiple”.

FAQ

How do I resize an image in ComfyUI?

Add the Upscale Image node, set width and height, and choose crop center to keep the aspect ratio. It shrinks as well as enlarges.

How do I keep the aspect ratio when resizing?

Set width or height to 0 in Upscale Image, or use Upscale Image By, Scale Image to Total Pixels or Scale Image to Max Dimension.

What’s the best resize method in ComfyUI?

area for shrinking, lanczos for enlarging, nearest-exact for pixel art and hard masks.

Does resizing add detail?

No. Resizing only interpolates pixels. Use an upscale model or a second sampling pass to add detail.

How do I crop an image in ComfyUI?

Use the Crop Image node and set its crop region, or resize with crop set to center.

Why should sizes be multiples of 8?

Most image models work on a latent 8 times smaller than the image, so other sizes get rounded or cropped. Newer models may prefer 16 or 64.

Can I resize a mask the same way?

Yes. Resize Image/Mask accepts masks, and its match size option makes a mask match its image exactly.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Woman in a server room holding a tablet with a RESIZE card, hook resize any image