Image Resize Square
Square images for models that demand exact sizes
- image
- mask
- image
- mask
Some models are picky about dimensions. SDXL wants its 1024s, and plenty of checkpoint families behave badly if you hand them 768x1344 when they're tuned for squares. Image Resize Square exists so you never have to compute "what's the nearest 1:1 that won't break this sampler" by hand - it snaps an image (and its mask, together) to a preset square size.
It's part of the same "image resize" family as the pack's Gemini and GPT-image adapters, and it inherits their mechanism: you pick a preset, it figures out how to fit your source into it, and it returns both the resized image and a mask that went through the exact same transform. That synchronized mask output is the real selling point - half the time you resize for a mask-aware workflow (inpainting, control conditioning), and most resize nodes silently drop your mask on the floor. This one doesn't.
The inputs that matter
- preset_size -
auto(default),auto (0.5k | 1k), or a fixed square:[0.25k] 256x256,[0.5k] 512x512,[1k] 1024x1024,[2k] 2048x2048,[4k] 4096x4096. The two auto options pick the nearest preset by your source's size;auto (0.5k | 1k)restricts the search to 512/1024, which is the sensible default for diffusion-sized work. Fixed presets are for when you know exactly what the model demands. - fit -
crop,pad, orstretch(defaultcrop).cropscales the short edge up and center-crops - no distortion, but you lose edges.padletterboxes withpad_color.stretchjust warps everything into the square; use it only when you genuinely don't care about aspect ratio. - pad_color - default
"1.0"(white). Accepts hex, named colors,r,g,btuples. Only matters inpadmode. - image / mask - both optional; if you connect a mask it rides along through whatever fit you chose.
Outputs: image and mask, both IMAGE/MASK tensors at the exact target resolution.
Why you'd actually use it
Two main workflows. First, pre-processing for models with rigid input sizes - resize to 1024 before a square-only upscaler or an image-conditioning encoder, and let your crop-vs-pad choice decide whether you keep composition or edges. Second, batch alignment: when you're feeding several images into a batch node that has to unify sizes anyway, squaring them first keeps the result predictable instead of whatever the batch node decided to pad.
Installing it
Via ComfyUI Manager, search "ComfyUI 1hewNodes" and install, then restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Restart ComfyUI after either path. Fair warning: the pack's requirements are bulky (opencv, scikit-image, rembg, ultralytics and friends) because the same repo ships detection and background-removal nodes. That install cost is shared by every node in the pack, including this lightweight one.
Gotchas
crop mode is destructive - whatever hangs off the sides is gone, so if you're resizing something you'll paste back onto a full canvas, pad is usually the safer call. And the auto modes pick based on your source's current dimensions, so resize (or don't) before you expect a specific preset to win. None of this is surprising behavior, but it's worth one mental pass before you blame the node for a square you didn't want.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| preset_size | COMBO | auto | 7 options: auto, auto (0.5k | 1k), [0.25k] 256x256 (1:1), [0.5k] 512x512 (1:1), [1k] 1024x1024 (1:1), [2k] 2048x2048 (1:1), +1 |
| fit | COMBO | crop | 3 options: crop, pad, stretch |
| pad_color | STRING | 1.0 | — |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |