Nodes/Various ComfyUI Nodes by Type/Image Resize to Square
ComfyUI Node

Image Resize to Square

Force any image into a perfect square

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Image Resize to Square
  • image
  • IMAGE
size512
interpolation_mode

You have an image at some awkward resolution, and the next thing in your graph wants a square. That's the whole job here. JWImageResizeToSquare takes an IMAGE and spits out a size by size version of it, nothing more, nothing less. It lives in jamesWalker55's grab-bag pack "Various ComfyUI Nodes by Type," which is exactly what it sounds like: a pile of small single-purpose utility nodes grouped by file. You don't install this pack because Reddit told you to. You install it because one specific node like this one solves the problem in front of you.

What it actually does

Both sides of the image get resized to the same number. That's the part people miss. There's no crop option, no letterbox, no "fit and pad" mode, just a single size field. So if you feed it a 16:9 frame, it doesn't crop to the middle square or pad the edges. It squashes the whole thing to size by size, and a wide image comes out visibly stretched. If your input was already square, great, it just scales. If it wasn't, know that going in.

That behavior is fine, even ideal, for a bunch of real uses. Square is the native shape a lot of pipelines like: SD 1.5 was happiest around 512, SDXL around 1024, and a lot of dataset-prep and reference-image steps just want everything normalized to one square size so a batch is uniform. When distortion doesn't matter (you're building a thumbnail grid, feeding a model that's going to re-crop anyway, or you genuinely want the stretch), this is the shortest path to it.

The inputs that matter

  • size (default 512): the edge length of the output square, in pixels. This is your one real knob. Set it to whatever your downstream model wants.
  • interpolation_mode: how pixels get resampled. bicubic is the smooth, safe default for photos and generated images. bilinear is a hair softer and cheaper. nearest (and nearest exact) do no blending at all, keeping hard pixel edges, which is what you want for masks, pixel art, or anything where a blurred edge would be wrong.

The output is a single IMAGE you wire into whatever comes next, a VAE encode, a preview, a save, a ControlNet preprocessor, anything that eats an IMAGE.

Installing it

Easiest route is ComfyUI Manager: open Manager, search for "Various ComfyUI Nodes by Type" or the author jamesWalker55, install, restart. If you'd rather do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/jamesWalker55/comfyui-various

then restart ComfyUI. Good news on dependencies: this node is pure image math, no model files to download and no extra Python packages. The only pip install the pack's README mentions (OpenEXR) is for an unrelated optical-flow loader, not for anything here. Worth a reminder that any custom node is arbitrary Python running on your machine, so install from sources you trust and lean on Manager for the well-known ones.

Where people get tripped up

The one real gotcha is the stretch. If your subject comes out squished, that's not a bug, it's the node doing exactly what it says, and the fix is to crop or pad your image to square before this node rather than expecting it to preserve aspect ratio. It can't; there's nowhere in the inputs to tell it how.

Second, watch the interpolation on masks. Resize a mask with bicubic and you get soft gray fringes on the edges where you probably wanted a clean hard boundary. Use nearest for masks and line art.

And size technically accepts 0 because the minimum is 0, which gets you a zero-pixel image and an error downstream. Just don't. Pick a real resolution that matches your model.

CategoryjamesWalker55

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
sizeINT5120–99999
interpolation_modeCOMBO4 options: bicubic, bilinear, nearest, nearest exact

Outputs (1)

NameTypeDescription
IMAGEIMAGE