Nodes/SimpleSyrup/Resize Image to Target
ComfyUI Node

Resize Image to Target

Aspect modes, GPU Lanczos, and a mask that rides along

By Artificial-Sweetener·Created 3 months ago·Updated 12 days ago· 2
Resize Image to Target
  • image
  • mask
  • image
  • width
  • height
  • mask
width1024
height1024
resize_modeKeep AR
samplinglanczos
processorgpu
divisible_by1
crop_positioncenter
pad_color0, 0, 0
max_batch_size0
sinc_window3
precisionfp32

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 (with crop_position choosing the anchor and pad_color - default 0, 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.

CategorySimpleSyrup/Image

Inputs (13)

NameTypeDefaultDescription
imageIMAGEImage batch to resize to the target dimensions.
widthINT10241–16384Target width in pixels before divisibility rounding.
heightINT10241–16384Target height in pixels before divisibility rounding.
resize_modeCOMBOKeep ARHow aspect ratio is handled. Stretch fills exactly, crop trims overflow, and pad fills empty space.
samplingCOMBOlanczosResize filter. Sharper filters preserve detail but can show more ringing.
processorCOMBOgpuProcessor used for resizing. GPU is usually faster; CPU can reduce GPU memory pressure.
divisible_byINT11–4096Round final dimensions to a multiple of this value for model or latent-size compatibility.
crop_positionCOMBOcenterAnchor used when crop mode trims overflow from the resized image.
pad_colorSTRING0, 0, 0RGB color used to fill empty space in pad mode.
max_batch_sizeINT00–4096Maximum images resized at once. Lower values reduce memory use; 0 processes the full batch together.
sinc_windowINT31–8Lanczos window size. Higher values can look sharper but may add ringing.
precisionCOMBOfp32Math precision for resizing. Lower precision can save memory but may slightly change results.
maskoptMASKOptional mask to resize with the image batch.

Outputs (4)

NameTypeDescription
imageIMAGEResized image batch after aspect-ratio handling and divisibility rounding.
widthINTFinal image width in pixels.
heightINTFinal image height in pixels.
maskMASKResized mask aligned to the output image size.