Nodes/MiniMax H3 Image Prep/H3 Aligned Image Resize
ComfyUI Node

H3 Aligned Image Resize

Feed it 32-aligned pixels

By artvandelay18160·Created about a month ago·Updated about a month ago· 1
H3 Aligned Image Resize
  • image
  • image
  • width
  • height
  • aspect_ratio
short_edge512
alignment32
resize_modecrop
anchorcenter
resamplinglanczos

The name says "H3," but this node never touches MiniMax's servers - no API key, no network call, no license check. It's pure image math that solves one annoying problem: H3-style pipelines want their input tensors at resolutions aligned to multiples of 32, and hand-rounding every source to some magic size is busywork you shouldn't think about at 2 a.m. This node takes whatever IMAGE batch you throw at it, keeps the aspect ratio, and hands back a clean 32-aligned version plus the numbers you need downstream.

It's a one-node pack from an unknown author (zero community footprint, zero docs beyond the README), so treat it as a utility, not infrastructure. But the code is short, readable, and does exactly one thing well - which is more than most preprocessing nodes can say.

Why 32-aligned even matters

Video and image backbones derived from VAE-style tokenizers - MiniMax H3 among them - patch their input into tiles and get finicky when spatial dimensions don't divide cleanly. H3's native 2K output runs off a 1440px short edge, so "aligned and in the right aspect ratio" is a real requirement, not superstition. This node is the front-end for that: pick a short edge (512, 768, or whatever your local H3 pipeline expects), and it derives the long edge from your source's actual aspect ratio, rounded to the nearest alignment multiple.

One honest caveat: the H3 weights themselves are geofenced out of the US, EU, UK and South Korea under the MiniMax H3 Community License. The node doesn't care - it's license-agnostic resize math that works for any 32-aligned model. If you're in an excluded region, it's still useful for other aligned pipelines; just don't run it in service of unlicensed H3 weights.

How the math works

The core is target_dimensions: for a landscape or square source, the short edge becomes the height; for portrait, it becomes the width. The long edge is short_edge × (source long / source short), rounded to the nearest alignment multiple with exact half-way cases rounding up - so 2368×1792 at short edge 512 becomes 672×512, and at 768 it becomes 1024×768.

Then three modes reconcile your image to that target box:

  • crop (default) - crops to the target aspect ratio first, then resizes. No distortion, but you lose whatever the crop cuts off.
  • pad - fits the whole image inside the target canvas on black padding. Nothing lost, but the model sees black bars, which some pipelines hate.
  • stretch - resizes straight to target dims. Distorts unless the source already matches. You'll rarely want this.

anchor decides where crop or pad sits - center, any edge, or any corner - and resampling picks the filter. Fun detail buried in the source: lanczos goes through Pillow per-image, while bicubic/bilinear/nearest use torch's interpolate with antialiasing. Both handle batches fine.

The inputs that matter

You mostly set three of them:

  • short_edge - the aligned short side, any positive multiple of 32. Default 512.
  • alignment - the rounding multiple for the long edge. Default 32; drop it to 16 if you need finer granularity.
  • resize_mode - crop, pad, or stretch. Default crop.

The anchor and resampling widgets have sane defaults (center, lanczos) and you can leave them alone until a specific output looks wrong.

Outputs are the processed image, the target width, height, and the computed aspect_ratio (a float). Feed the INT outputs straight into Empty Latent Image so the rest of the graph matches what this node produced - no eyeballing.

Installing it

The README's "install" is the whole story, because there are no extra dependencies - just torch, numpy, and Pillow, which ComfyUI already ships:

cd ComfyUI/custom_nodes
git clone https://github.com/artvandelay18160/H3-image-prep

Restart ComfyUI and the node appears under image/preprocessing. Manager users can just search "H3-image-prep." No model downloads, no VRAM cost, nothing to babysit.

Where people get burned

  • Typing a short edge that isn't a multiple of 32. The slider steps by 32, but the widget accepts typed values - and the code hard-fails with ValueError: short_edge must be a positive multiple of 32. Type 600 and the run dies mid-graph.
  • pad surprises you. Padding a 16:9 source into a portrait canvas gives a portrait image with massive black bars, and the model will happily generate into those bars. If that's not what you wanted, that's what crop is for.
  • It's young. One node, one author, no issue tracker chatter. It's tiny and auditable, so that's fine for a utility - just read the ~200 lines before building anything on it.

Reach for this when you're assembling an H3-style workflow and you're tired of doing aspect-ratio arithmetic by hand. It's small, deterministic, and exactly the kind of node that makes a fiddly pipeline feel like it just works.

Categoryimage/preprocessing

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
short_edgeINT51232–8192
alignmentINT321–1024
resize_modeCOMBOcrop3 options: crop, pad, stretch
anchorCOMBOcenter9 options: center, top, bottom, left, right, top_left, +3
resamplingCOMBOlanczos4 options: lanczos, bicubic, bilinear, nearest

Outputs (4)

NameTypeDescription
imageIMAGE
widthINT
heightINT
aspect_ratioFLOAT