Nodes/Comfyui HiFORCE Plugin/Image Enlargement - Zoom and Crop into a Square
ComfyUI Node

Image Enlargement - Zoom and Crop into a Square

Fit a Non-Square Image Into a Square Without Chopping the Subject's Head Off

By hiforce·Created 3 years ago·Updated 2 years ago· 12
Image Enlargement - Zoom and Crop into a Square
  • images
  • result
expansion_multiple1.20
size1024
align

Every img2img user hits the same wall: your reference photo is 3:2 landscape, and the model you're using wants a square - for SDXL, native 1024×1024. The naive fix is a center crop, and the naive crop is how you lose someone's head or their feet. HfImageAutoExpansionSquare is the pack's answer to that: it zooms the image into the frame and re-crops it so the subject survives, in the orientation you care about.

The node's full display name spells out the behavior - "Image Enlargement - Zoom and Crop into a Square" - and the mechanism is exactly that. From the source: your image gets pasted onto a white canvas scaled up by expansion_multiple (so there's now margin around it), positioned vertically according to the align setting, resized so its height matches your target size, then center-cropped horizontally into a size × size square. Net effect: the picture is zoomed slightly so the important axis fills the square, and the crop bias is something you control rather than a coin flip.

The inputs that actually matter:

  • images - the IMAGE tensor (batch-friendly, works on a whole folder at once)
  • expansion_multiple - FLOAT, default 1.2, how much to blow up the canvas before cropping. Lower zooms less and crops more of the frame; crank it up and you're zooming way in.
  • size - INT, default 1024, the square edge length (512–1024)
  • align - bottom / center / top, which third of the frame survives the vertical trim. This is the one people get wrong.

Here's the trap, and it's worth reading twice: the default is bottom, not center or top. If you're fixing a portrait where the face matters, bottom will crop exactly where you don't want it - switch to top to keep the head, bottom to keep the feet, center for a balanced middle. Most people's first run with this node is the "why is her forehead gone" run, and the answer is always align.

The output is a single result IMAGE, ready to feed into an img2img sampler or ControlNet preprocessing. The typical flow: load a photo → this node → VAE encode → sampler at a square resolution the model natively handles.

One honest caveat about what it does not do. The padding canvas is solid white. So when the crop leaves part of that margin visible, you get white bars - this is a zoom-and-crop tool, not an outpainting tool that fills in context. If expansion_multiple is high and your source is wide, expect white on the sides and plan around it (a mask or inpaint pass can clean it up). Also, this is the same ImageCropper abstraction the pack's HfLoadImageWithCropper uses, and it sits on the detect-crop-resample-paste foundation of ComfyUI-Impact-Pack, which the README tells you to install first.

It's part of Comfyui HiFORCE Plugin (HiFORCE, hiforce.net) - a pack whose reputation is really built on its sampler nodes, with these image helpers as the supporting cast. Install via ComfyUI Manager by searching "Comfyui HiFORCE Plugin," or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/hiforce/comfyui-hiforce-plugin.git
cd comfyui-hiforce-plugin
pip install -r requirements.txt

Restart ComfyUI and the node appears under HiFORCE → Image → Zoom. Requirements are just torch, numpy, Pillow, and requests - nothing heavy, and this node downloads no models.

Last word: this pack has almost no community footprint - we searched Reddit and found nothing meaningful about it. It's a niche, author-maintained project, so the GitHub wiki and the source (which is short and readable) are your real documentation. Don't expect a flood of forum answers if you get stuck.

CategoryHiFORCE/Image/Zoom

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
expansion_multipleFLOAT1.200.01–100
sizeINT1024512–1024
alignCOMBO3 options: bottom, center, top

Outputs (1)

NameTypeDescription
resultIMAGE