Nodes/Comfyui HiFORCE Plugin/Init Image to limited Size
ComfyUI Node

Init Image to limited Size

Cap Your Img2Img Resolution Before Your VRAM Does

By hiforce·Created 3 years ago·Updated 2 years ago· 12
Init Image to limited Size
  • image
  • IMAGE
mas_size512

Img2img has a dirty secret: it will happily try to encode a 3000×4000 source photo, and then your 8GB card will cough, the VAE will churn, and you'll wonder why a "simple" edit took ninety seconds and a swap file. The fix is almost always the same - cap the resolution before it hits the encode - and that's exactly the one knob this node gives you.

HfInitImageWithMaxSize downscales an image so its longest side is at or below a size you choose, keeping the aspect ratio intact and snapping the result to the latent grid (multiples of 8, the same constraint that makes HfResizeImage behave). Feed it a 3000px-tall portrait with a max of 1024 and out comes a ~683×1024 image ready for the sampler. That's it. One knob, one job.

Two details matter. First, it only ever shrinks - if your image is already smaller than the cap, it comes back untouched. There's no upscaling here, so you can safely drop it into a workflow as a "floor" guarantee without worrying it'll inflate your images. Second, the parameter is called mas_size - yes, that's a typo for max_size, and it's the author's typo, immortalized in the input name. Don't go looking for the "correct" spelling; the socket is mas_size, default 512, range 256 to 2048.

The mechanism, straight from the source: it compares width against height, and if the longer side exceeds your cap, it scales the shorter side proportionally - then runs the result through the pack's resize helper, which handles the multiple-of-8 snapping. It's a "normalize to fit a model's native resolution" node more than anything else.

Honestly, this is the kind of node you reach for when you're assembling a repeatable workflow, not a one-off experiment. The exact scenario: you've got a folder of reference images at wildly different resolutions, you want to feed them all into img2img or a ControlNet at a consistent size, and you can't be bothered to compute aspect-ratio-preserving dimensions by hand every time. Drop this in with a cap of 1024 for SDXL or 512 for SD 1.5-era models, and every input arrives at a size the model was built for. It also quietly protects you from the classic "hires.fix on a 3000px image" OOM, which is worth something by itself.

If you're comparing against core ComfyUI: ImageScaleToTotalPixels and friends do similar cap work, but this one bundles the latent-grid snapping and the "never upscale" behavior into a single parameter that's hard to misuse. Not a headliner, just a genuinely useful guardrail.

It ships in Comfyui HiFORCE Plugin from HiFORCE (hiforce.net), a pack whose reputation rests on its sampler nodes - Basic Sampler, Loopback Sampler, the mask-aware HfTwoStepSamplers - with these image utilities as supporting cast. Install via ComfyUI Manager (search "Comfyui HiFORCE Plugin") or:

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

Restart and it lands under HiFORCE → Image → Create. The README asks you to install ComfyUI-Impact-Pack first (a lot of the pack builds on its foundation), and the actual dependencies are just torch, numpy, Pillow, and requests - nothing heavy, and no model downloads for this node.

Caveat with teeth: this pack has almost no community footprint. We searched Reddit for it and came up empty. It's a niche, author-maintained pack you'll mostly discover through Manager, so when something surprises you, the GitHub wiki and the (short) source are your documentation.

CategoryHiFORCE/Image/Create

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
mas_sizeINT512256–2048

Outputs (1)

NameTypeDescription
IMAGEIMAGE