Nodes/Q Find Mask Size/Q Image Crop Calculator
ComfyUI Node

Q Image Crop Calculator

Four numbers that decide how much of your subject Hunyuan 3D actually sees

By angree·Created about a year ago·Updated about a year ago· 0
Q Image Crop Calculator
  • mask
  • width
  • height
  • x_offset
  • y_offset
step_size8
padding8
min_size520

The name is a lie, in a good way. Q Image Crop Calculator doesn't tell you the size of your mask - it turns a mask into a crop. You feed it the alpha from your background removal, it hands back four integers (width, height, x_offset, y_offset), and those wire straight into ComfyUI's built-in ImageCrop node. That's the whole node. There's exactly one of them in the pack, and it exists for one reason: making sure Hunyuan 3D 2.0 sees as much of your subject as physically possible in its 518×518 input.

Here's the problem it solves. Hunyuan 3D 2.0 (the non-mini, non-turbo build) takes a fixed 518×518 square image, and every pixel of that square is texture budget. Feed it a full uncropped photo and your subject might occupy 20% of those pixels; the rest is background the model dutifully turns into nothing. Tencent's 3D line took the open 3D-asset niche during 2025, but the quality ceiling is set by how much real detail you pack into that square. So the workflow is: cut the background out, crop to the subject, resize to 518×518, generate. This node is the "crop to the subject" step.

Mechanically it's simple and honest. The node takes the MASK tensor, keeps everything brighter than 0.1 as "subject," finds the bounding box, expands it by your padding, and then does the clever bit: it takes the larger of width and height, rounds up to your step_size, and enforces min_size - so you always get a square crop, centered on the subject, clamped to stay inside the image. That square-for-square thing is deliberate, because the 3D pipeline wants a square and nothing else. If the mask comes in empty, it doesn't error; it quietly returns a centered min_size square, so a failed background removal fails soft.

Three inputs actually matter, and here's the trap: the README's defaults are stale. It claims step_size 32 / padding 64 / min_size 256, but the real node (check the source) ships with step_size 8, padding 8, min_size 520. Trust the node, not the doc - the min_size default of 520 is basically Hunyuan's 518 rounded to the nearest step of 8, which is a decent hint at how it's meant to be used. padding (0–256) is the one you'll actually reach for: small subjects look lost with too much, and a tall full-body subject gets big empty sides because the crop is always square. step_size (4–128) is alignment for models that like multiples of 8/16/32. Keep them at default unless you have a reason not to.

Install is the easiest part of the whole thing. ComfyUI Manager, search "Q Find Mask Size" (the pack title), install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/angree/ComfyUI-Q_find-mask-size

Then restart ComfyUI. There are no model downloads, no CUDA surprises, no heavy deps - requirements.txt is just numpy>=1.24.0 and pillow>=10.0.0, both of which you almost certainly already have. Torch comes with ComfyUI. This is a "clone and forget it" node.

Where people get burned: the README is rough - the clone URL literally says YOUR_USERNAME, and the pack's own example workflow (Hunyuan3d_20_Batch_Cropping_Emmision.json) actually uses KJNodes' OptimalCropCalculator plus ImageCrop, not this node. Don't expect that workflow to open with just this pack installed. If you're not doing Hunyuan 3D work, you don't need this node at all - any crop calculator does the same job and OptimalCropCalculator gives you a non-square option. But for its one job - packing the most subject into a 518×518 square - it's exactly the right amount of tool: zero UI, four numbers, one purpose.

Categoryimage/crop

Inputs (4)

NameTypeDefaultDescription
maskMASK
step_sizeINT84–128
paddingINT80–256
min_sizeINT520128–4096

Outputs (4)

NameTypeDescription
widthINT
heightINT
x_offsetINT
y_offsetINT