Resize Image to Target
Aspect modes, GPU Lanczos, and a mask that rides along
- image
- mask
- image
- width
- height
- mask
Resizing an image sounds like the most solved problem in image software, until you need to do it properly inside a node graph: match a target size without wrecking the aspect ratio, keep a mask in lockstep with the image it belongs to, and do it fast enough that a batch doesn't turn into a coffee break. SimpleSyrup.ResizeImageToTarget is the "yes, all of that" node, and it's the piece you reach for when prepping images for hi-res workflows or aligning reference batches.
The core is a resizer with real options instead of one hidden interpolation mode:
width/height- target dimensions (default 1024²), before divisibility rounding.resize_mode- the aspect handling. Stretch fills exactly (distorts); Keep AR preserves aspect; crop fits inside then trims the overflow; pad fits inside and fills the empty space (withcrop_positionchoosing the anchor andpad_color- default0, 0, 0- the fill).sampling- the filter. lanczos is the default, and it's the right default: sharper, preserves detail.sinc_window(default 3) trades a bit of sharpness for less ringing - that's the "it looks crunchy" knob.processor- gpu (default) or cpu. GPU is faster; CPU frees VRAM. On a 16GB card mid-workflow, CPU is your friend.divisible_by- round the final dimensions to a multiple of this. Set it to 8 or 16 when the result is feeding a model that cares about latent-friendly sizes.max_batch_size- 0 processes the whole batch at once; a lower number processes in chunks to cap memory.precision- fp32 default; dropping it saves memory at slight quality cost.
The feature that separates it from a generic resize node is the optional mask input and output. Pass a mask in alongside the image batch and it comes out the other side resized to exactly the output dimensions, aligned with the resized image. If you're resizing an image and its mask together - which you have to do constantly in inpainting and regional workflows, and which stock nodes make you do in two separate resize nodes hoping they agree - this is the single-node fix. A misaligned mask is one of those bugs that looks like model failure and is actually just geometry.
Outputs: image, width, height (the final numbers, after aspect handling and rounding - handy for wiring into latent sizing), and mask when one was supplied.
It pairs naturally with the pack's context: author of this pack lived in WebUI-land where "resize for hires fix" was a button, and this is the graph version with the guardrails - GPU Lanczos via TorchLanc (a dependency the pack installs), chunked batches, and paired masks. Use it to standardize a mixed-size batch before it hits a batch-expecting node, and you've killed a whole class of "batch shape mismatch" errors.
Install: the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Artificial-Sweetener/SimpleSyrup
cd SimpleSyrup && pip install -r requirements.txt
or ComfyUI Manager → search SimpleSyrup → Install → restart. TorchLanc comes with the pack's requirements. If GPU resizing errors on an older card, switch processor to cpu - the feature set is identical, only the speed changes.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Image batch to resize to the target dimensions. | |
| width | INT | 10241–16384 | Target width in pixels before divisibility rounding. |
| height | INT | 10241–16384 | Target height in pixels before divisibility rounding. |
| resize_mode | COMBO | Keep AR | How aspect ratio is handled. Stretch fills exactly, crop trims overflow, and pad fills empty space. |
| sampling | COMBO | lanczos | Resize filter. Sharper filters preserve detail but can show more ringing. |
| processor | COMBO | gpu | Processor used for resizing. GPU is usually faster; CPU can reduce GPU memory pressure. |
| divisible_by | INT | 11–4096 | Round final dimensions to a multiple of this value for model or latent-size compatibility. |
| crop_position | COMBO | center | Anchor used when crop mode trims overflow from the resized image. |
| pad_color | STRING | 0, 0, 0 | RGB color used to fill empty space in pad mode. |
| max_batch_size | INT | 00–4096 | Maximum images resized at once. Lower values reduce memory use; 0 processes the full batch together. |
| sinc_window | INT | 31–8 | Lanczos window size. Higher values can look sharper but may add ringing. |
| precision | COMBO | fp32 | Math precision for resizing. Lower precision can save memory but may slightly change results. |
| maskopt | MASK | Optional mask to resize with the image batch. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | Resized image batch after aspect-ratio handling and divisibility rounding. |
| width | INT | Final image width in pixels. |
| height | INT | Final image height in pixels. |
| mask | MASK | Resized mask aligned to the output image size. |