π¦ BoxResize
Resize to a generation-friendly resolution, and hand the recipe to BoxReinsert
- image
- image
- resize_metadata
BoxResize is the utility node in the BoxBox chain that does exactly one job well: it resizes your cropped region to a resolution a diffusion model actually likes, and it hands the details of that resize forward so BoxReinsert can put the result back in the right place. Think of it as the middle step between "I cut this little piece out" and "now feed it to a sampler."
The reason it exists is that generation wants round, model-friendly resolutions. BoxResize ships with the standard SDXL-style presets - 1024x1024 square, 896x1152 and 832x1216 portrait, 1152x896 and 1344x768 landscape, and the ultrawide 21:9 variants - so a small crop of a face or an object gets upscaled to a resolution where the model can actually add detail instead of mangling it.
How it works
It resizes the tensor with torch.nn.functional.interpolate, choosing between bilinear, bicubic, and nearest interpolation. bilinear is the default and the safe choice; nearest exists for pixel-art and hard-edged content where you want zero blending.
Here's the quirk worth knowing: with keep_aspect_ratio on (the default), the node anchors on the width of your chosen preset and derives the height from your image's own aspect ratio. The preset's height is ignored. So if you pick "1:1 Square 1024x1024" for a portrait crop, you do not get a square - you get 1024 wide by whatever preserves your portrait proportions. That's usually what you want for a crop-and-stitch workflow, but it surprises people who expect presets to be strict target dimensions. Turn keep_aspect_ratio off if you genuinely want a forced 1024x1024 (and accept the stretch).
The inputs that matter
- image - usually the
cropped_imagefrom BoxCrop. - size - the preset dropdown, default
Custom. - keep_aspect_ratio - default
true, see the quirk above. - interpolation_mode -
bilinear/bicubic/nearest. - width / height - optional, used when
sizeisCustom. Range 64β8192 in steps of 8, defaults 1024.
Two outputs: image (the resized tensor, ready for VAEEncode) and resize_metadata, a JSON string carrying original and resized dimensions plus the scale factors. That metadata is what BoxReinsert consumes to know how much it needs to shrink the generated image back to crop size.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/mercu-lore/BoxBox
Then restart ComfyUI (Manager users: search "BoxBox"). Dependencies are torch, numpy, and Pillow - all already present in a stock ComfyUI, no model downloads. This is a genuinely light pack.
Common issues
- "Why isn't my square preset square?" See the keep_aspect_ratio behavior above. If you want a hard target size, either disable keep_aspect_ratio or use the Custom width/height inputs.
- Output dimensions look weird when paired with BoxReinsert. The resized image gets squashed back to exactly the crop box size on reinsert (LANCZOS), so a bad aspect choice here distorts the pasted region. Keep aspect ratio on unless you're deliberately filling the box.
- No
resize_metadataoutput. If you're using an older BoxBox clone, update it - the metadata output is what makes the resize-to-reinsert handoff work.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| size | COMBO | Custom | 10 options: Custom, 1:1 Square 1024x1024, 3:4 Portrait 896x1152, 5:8 Portrait 832x1216, 9:16 Portrait 768x1344, 9:21 Portrait 640x1536, +4 |
| keep_aspect_ratio | BOOLEAN | true | β |
| interpolation_mode | COMBO | bilinear | 3 options: bilinear, bicubic, nearest |
| widthopt | INT | 102464β8192 | β |
| heightopt | INT | 102464β8192 | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |
| resize_metadata | STRING | β |