Image Advanced Resize
Resize, grayscale, and get your aspect ratio as a bonus
- image
- width
- height
- ratio
- aspect_type
- aspect_ratio_common
- output_image
Image Advanced Resize is a Swiss-army preprocessing node: it resizes an image (by target megapixels or by explicit dimensions), optionally converts it to grayscale, and alongside the processed image hands you a stack of metadata - width, height, ratio, landscape/portrait/square, and a human-readable 16:9-style ratio. One node replaces what would otherwise be several.
The two modes cover the two resize jobs people actually have. By megapixel is the modern one: you tell it "I want this to be a 1 MP image" and it keeps the aspect ratio and lands right at that size - exactly what you want when normalizing a batch of images to a model's native resolution (SDXL territory, Flux territory, whatever). By dimensions is the classic fit-to-box resize: give it a max width and height and it scales to fit, respecting the aspect ratio unless you tell it not to. There's even a divisible_by option (1/2/4/8/16/32/64) to round the result to a latent-friendly multiple, which saves you the "the VAE hates odd dimensions" headache later.
How it works
The image comes in as a ComfyUI tensor, gets converted to PIL, and - if you've ticked resize - resized with LANCZOS. The by-megapixel path solves for dimensions that hit your target MP at the source's aspect ratio; the by-dimensions path fits within your width/height box. Then rounding to divisible_by happens as nearest multiple, and the result is converted back to a tensor. Grayscale is a straightforward per-pixel luminance conversion. Finally it computes the ratio and a greatest-common-divisor-reduced w:h label.
One implementation quirk worth knowing: the grayscale pass is a plain Python loop over pixels, not vectorized. Fine for a single image, but don't batch a thousand large frames through it and expect speed.
Inputs and outputs
The ones you'll actually set:
image(IMAGE) - required input.resize(BOOLEAN, defaultfalse) - the master switch. Off by default, which means the node is a metadata pass-through until you tick it.resize_mode(enum, defaultby_megapixel) -by_dimensionsorby_megapixel.target_megapixel(FLOAT, default1) - used in by-megapixel mode.new_width/new_height(INT, default256) - used in by-dimensions mode.divisible_by(enum, default1) - rounding multiple.grayscale(BOOLEAN, defaultfalse),keep_aspect_ratio(BOOLEAN, defaulttrue).
Outputs: width/height (INT), ratio (FLOAT), aspect_type (STRING: landscape/portrait/square), aspect_ratio_common (STRING like "16:9"), and output_image (IMAGE) - the processed image, which is the only output you'd normally wire onward. The metadata outputs are handy for driving other nodes: feed width/height into an Empty Latent, or log aspect_ratio_common to a text node.
Installing it
Part of the Skycoder Tools pack:
cd ComfyUI/custom_nodes
git clone https://github.com/skycoder182/comfyui-skycoder-tools.git
# then restart ComfyUI
Or ComfyUI Manager → "Install Custom Nodes" → search "Skycoder Tools" → Install → restart. No models, no extra dependencies.
Common issues
The top gotcha is the resize default: it's off, so if you wire this in expecting a resized image and nothing changes, check that checkbox first. Second, rounding is to the nearest multiple, not down, so divisible_by can push a result slightly above your target - usually fine, occasionally surprising if you were sizing for a tight VRAM budget. And keep the slow grayscale loop in mind before you point it at a big batch.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| resize | BOOLEAN | false | — |
| grayscale | BOOLEAN | false | — |
| keep_aspect_ratio | BOOLEAN | true | — |
| resize_mode | COMBO | by_megapixel | 2 options: by_dimensions, by_megapixel |
| target_megapixelopt | FLOAT | 1.0 | — |
| new_widthopt | INT | 2561–4096 | — |
| new_heightopt | INT | 2561–4096 | — |
| divisible_byopt | COMBO | 1 | 7 options: 1, 2, 4, 8, 16, 32, +1 |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| ratio | FLOAT | — |
| aspect_type | STRING | — |
| aspect_ratio_common | STRING | — |
| output_image | IMAGE | — |