Image Resize to 8x
Resizing that never breaks your composite-back step
- pixels
- mask_optional
- image
- mask
- width
- height
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, orpad to ratio. Crop/pad target theside_ratiostring (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), orscale_factor(a straight multiplier). Leave the others at 0. resize_mode-reduce size only,increase size only, orany, 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 optionalall_size_16x-disable,crop, orresize: 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.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| action | COMBO | 3 options: resize only, crop to ratio, pad to ratio | |
| smaller_side | INT | 00–8192 | — |
| larger_side | INT | 00–8192 | — |
| target_width | INT | 00–8192 | — |
| target_height | INT | 00–8192 | — |
| scale_factor | FLOAT | 0.00–10 | — |
| resize_mode | COMBO | 3 options: reduce size only, increase size only, any | |
| side_ratio | STRING | 4:3 | — |
| crop_pad_position | FLOAT | 0.500–1 | — |
| pad_feathering | INT | 200–8192 | — |
| all_szie_8x | COMBO | 3 options: disable, crop, resize | |
| mask_optionalopt | MASK | — | |
| all_size_16xopt | COMBO | 3 options: disable, crop, resize |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| width | INT | — |
| height | INT | — |