ComfyUI Node

Image Resize to 8x

Resizing that never breaks your composite-back step

By zhangp365·Created 2 years ago·Updated 5 months ago· 134
Image Resize to 8x
  • pixels
  • mask_optional
  • image
  • mask
  • width
  • height
action
smaller_side0
larger_side0
target_width0
target_height0
scale_factor0.0
resize_mode
side_ratio4:3
crop_pad_position0.50
pad_feathering20
all_szie_8x
all_size_16x

This is a resize node with one specific job baked into its name: whatever else it does, the output dimensions land on a clean multiple of 8. That sounds like a footnote, but it's actually solving a real, specific bug class - the "why did my composited pixels shift by two rows" problem that shows up when you resize, generate, then paste back.

Why the 8x thing matters at all

VAEs for SD, SDXL, and Flux all work on an 8x downsampled latent grid - a 1024x1024 image becomes a 128x128 latent. If your image dimensions aren't evenly divisible by 8, something in the pipeline has to round, and that rounding is exactly what causes the "off by a few pixels" mismatch when you later use ImageCompositeMasked to paste a processed region back onto the original. This node - a modification of palant/image-resize-comfyui - forces the final size onto that grid up front, so nothing downstream has to guess.

The inputs that actually matter

There's a lot of surface area here because it supports several resize strategies at once, but you only need a few of them for any given use:

  • action - resize only, crop to ratio, or pad to ratio. Crop/pad target the side_ratio string (default "4:3").
  • One sizing method - pick exactly one: smaller_side/larger_side (resize by constraining one dimension), target_width/target_height (set both directly), or scale_factor (a straight multiplier). Leave the others at 0.
  • resize_mode - reduce size only, increase size only, or any, a guard rail so you don't accidentally upscale a source that's already close to your target.
  • crop_pad_position - 0 to 1, where the crop or pad anchors (0.5 = centered).
  • pad_feathering - softens the edge where padding meets real image, useful if you're feeding this into an outpaint-style workflow.
  • all_szie_8x (yes, that's really the spelling on the node) and the optional all_size_16x - disable, crop, or resize: the final alignment pass that guarantees the 8x (or 16x) grid, either by trimming a few pixels or rescaling to hit it.

Optional mask_optional lets a mask ride along through the same resize/crop/pad transform as the image, so it stays aligned with it.

Outputs

image, mask, width, and height - the last two are the actual final pixel dimensions, worth wiring into a debug preview or a downstream latent node so you can confirm what you actually got, since with this many overlapping resize modes it's easy to end up with a size you didn't expect on the first try.

Installing it

ComfyUI Manager: search "ComfyUI-utils-nodes." Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/zhangp365/ComfyUI-utils-nodes

Restart ComfyUI. No model downloads, no extra dependencies - pure image-processing Python.

Where people get tripped up

The main gotcha is setting more than one sizing method at once - target_width and scale_factor both non-zero, say - and getting an output you can't explain. Pick one path (target size, or a side constraint, or a scale factor) and leave the rest at their 0 default. Second: if you're chaining this before an inpaint-and-composite step and colors or edges still look slightly off at the seam, double-check all_szie_8x isn't set to disable - that's the setting actually doing the work this node is named for, and it's easy to assume it's on by default when it isn't.

Categoryutils/image

Inputs (14)

NameTypeDefaultDescription
pixelsIMAGE
actionCOMBO3 options: resize only, crop to ratio, pad to ratio
smaller_sideINT00–8192
larger_sideINT00–8192
target_widthINT00–8192
target_heightINT00–8192
scale_factorFLOAT0.00–10
resize_modeCOMBO3 options: reduce size only, increase size only, any
side_ratioSTRING4:3
crop_pad_positionFLOAT0.500–1
pad_featheringINT200–8192
all_szie_8xCOMBO3 options: disable, crop, resize
mask_optionaloptMASK
all_size_16xoptCOMBO3 options: disable, crop, resize

Outputs (4)

NameTypeDescription
imageIMAGE
maskMASK
widthINT
heightINT