NodeImagePre
Resize, empty latent, and upscale numbers — all in one prep node
- image
- mask
- image_resize
- mask_resize
- empty_latent
- batch
- width_resize
- height_resize
- ups
- width_ups
- height_ups
NodeImagePre is what NodeImageResize grows into when you stop just resizing and start building an actual image-to-image workflow. Give it an image (and optionally a mask), tell it how big the short side should be and how much you plan to upscale later, and it hands you four things at once: the resized image, the resized mask, a ready-to-use empty latent at the VAE-correct size, and the upscaled dimensions for the hi-res pass. It's from the same obscure little pack as the other two - KERRY-YUAN's ComfyUI_Simple_Executor, which has basically no community footprint - and it's the node of the three I'd actually build a graph around.
How it works
Three calculations, one pass. It takes your shortside, scales the image to fit it while keeping the aspect ratio, and rounds both dimensions up to multiples of 16 (width_resize/height_resize). It builds an empty_latent as zeros(batch, 4, h//8, w//8) - the standard 8× latent-space downsample with the four latent channels - so you get a sampling canvas whose size exactly matches the resized image, no manual math. Then it applies your ups factor to the resized dimensions and rounds those up to multiples of 8, giving you width_ups/height_ups for the upscale stage. The mask, when provided, is resized with NEAREST resampling - the right call, because nearest keeps hard edges crisp instead of feathering them like Lanczos would.
Inputs and outputs
Inputs: image (IMAGE), shortside (INT, default 800, step 16), batch (INT, default 1), ups (FLOAT, default 1.0), plus optional mask (MASK). Outputs:
image_resize(IMAGE) andmask_resize(MASK) - the aligned pair, ready for img2img or inpainting.empty_latent(LATENT) - wire into a KSampler when you want generation at exactly this size.batch(INT) - passthrough.width_resize/height_resize(INT) - the 16-multiple dimensions.ups(FLOAT) pluswidth_ups/height_ups(INT) - the 8-multiple upscale target.
The author's example: 800×600 image, shortside 768, ups 1.5 → resized 1024×768, upscaled 1536×1152. Clean numbers, no manual stepping.
How to actually use it
It's a front-end for a two-stage workflow: prep the input and the latent, sample, then upscale. The width_ups/height_ups ints feed an upscaler (or its target-size input), so the hi-res pass lands on a grid that keeps the latent sane. Per the KB's upscaling essay, remember what this node does not do: it computes numbers, it doesn't run an upscaler. "More pixels" and "more detail" are different jobs, and this is the pixels side - you still supply the ESRGAN/SeedVR2-style pass yourself.
Honest gotchas
batchis mostly a passthrough. The code builds the empty latent with the batch size, but the image and mask outputs are processed one frame at a time (the source squeezes off the first tensor entry). Feed it a batch and you get one image back. Treatbatchas "how big should the empty latent be," not "how many images will I get."mask_resizeis None when no mask is wired in. Don't run that output into a mask-consuming node expecting a tensor - gate it on having a mask, or just leave it dangling.- The empty latent is zeros, by design. It's a blank canvas for sampling, not a VAE encode of your image. If you want an img2img starting latent that preserves the input, VAEEncode the resized image instead.
- The latent dims are
resize_h // 8- exact because the resize dims are already multiples of 16.
Install
Standard for this pack - ComfyUI Manager (search ComfyUI_Simple_Executor), or:
cd ComfyUI/custom_nodes
git clone https://github.com/KERRY-YUAN/ComfyUI_Simple_Executor
Restart and you're done; no model downloads, no extra dependencies beyond what ComfyUI already has. It's a three-impression node that a surprising number of img2img workflows could use - if you find yourself stacking ImageScale, EmptyLatentImage, and two math nodes at the start of every graph, this collapses the whole front end into one box.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| shortside | INT | 800560–9600 | — |
| batch | INT | 1 | — |
| ups | FLOAT | 1.00 | — |
| maskopt | MASK | — |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| image_resize | IMAGE | — |
| mask_resize | MASK | — |
| empty_latent | LATENT | — |
| batch | INT | — |
| width_resize | INT | — |
| height_resize | INT | — |
| ups | FLOAT | — |
| width_ups | INT | — |
| height_ups | INT | — |