Nodes/ComfyUI-Tools/Image - Crop Image with Alpha
ComfyUI Node

Image - Crop Image with Alpha

The prep step your image-to-3D node quietly assumes

By visualbruno·Created 8 months ago·Updated a day ago· 5
Image - Crop Image with Alpha
  • image
  • image
◄padding0►
◄remove_backgroundfalse►
◄max_size2048►
◄square—►

The one image node in a 3D utility pack

ComfyUI-Tools is visualbruno's utility pack - the same author behind ComfyUI-Hunyuan3d-2-1 and ComfyUI-Trellis2, which is to say the person who's been glue-ing image-to-3D models into ComfyUI for a while. Most of the pack is mesh plumbing. This node is the odd one out, and it's here because image-to-3D needs it: every one of those models was trained on a single, centered, background-free subject, and every one of them degrades when you hand it a tall photo with a busy backdrop. If you have been doing "remove background, crop, resize" by hand in Photoshop before feeding Hunyuan3D or TRELLIS, this is that step wired into the graph.

What it does, exactly

It is not an alpha producer despite the name - it consumes alpha. Feed it an RGBA image (or let it cut the background out for you), and it returns one square, tightly-cropped, plain-background image sized for a 3D model's image input.

Read from the source, the order of operations is: optionally run rembg's remove, downscale so the longest side is at most max_size (never upscales), find the bounding box of pixels where alpha is above roughly 80% of 255, expand that box to a square around its center, crop, then multiply RGB by alpha and hand back a plain three-channel image. That last step is the tell - the alpha is baked in, so transparent areas become black. Black is what these models want; it reads as "nothing here" rather than as a random background.

Inputs worth touching

  • image - standard IMAGE. A batch works; each frame is handled separately.
  • remove_background - off by default. Turn it on and the node calls rembg (the pack's requirements.txt installs it) instead of expecting you to arrive with alpha.
  • max_size - 2048 by default, 512–8192 in steps of 128. This is the ceiling on the longest side before the crop, so it's your VRAM/quality dial for the downstream 3D model.
  • padding - 0 by default, 0–1024. Adds a black border after the crop; a few dozen pixels gives the model a bit of breathing room around the subject instead of touching the frame edge.

One output: image, and it wires into whatever the 3D model takes as its reference image.

Install

No model files to download by hand. The pack is on the registry, so ComfyUI Manager → search "ComfyUI-Tools" → install → restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/visualbruno/ComfyUI-Tools

Then install its requirements (trimesh and rembg - Manager does this for you if you install through the UI) and restart ComfyUI. Fair warning: there is no README in the repo at all right now, it's two days old, so the requirements.txt and the node source are the documentation. The first run with remove_background on will quietly fetch rembg's u2net weights before it does anything.

Where people get burned

It needs an alpha channel, and it will crash without one. remove_background off plus a plain RGB image throws an index error on the alpha channel - there is no graceful "treat it as opaque" fallback. So either tick the box or feed it something with real alpha.

The output has no alpha. If you were hoping to grab a cutout to composite elsewhere, this node gives you a black background instead of a transparent one. Use the RMBG/BiRefNet route from our background removal notes when the destination is 2D.

rembg here means u2net. The node calls rembg with no model argument, so you get the old default, which is the one people complain about on flyaway hair and semi-transparent edges. On a hard-edged object it's fine. On a furry creature, expect to be cleaning up the black skull.

Batch mode squashes to a common size. When you feed a batch, every frame gets resized to the largest height and width in that batch with a bicubic pass. If the frames aren't already the same shape - different crops of different subjects, say - they get stretched rather than letterboxed, and that resample is not free in sharpness terms.

A square crop can run off the canvas. The square is centered on the subject's bounding box, so a subject hugging one edge leaves black where the square falls outside the frame. That's usually harmless; it just looks odd if you're eyeballing the output.

CategoryVisualBrunoTools/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE—
paddingINT00–1024—
remove_backgroundBOOLEANfalse—
max_sizeINT2048512–8192—
squareBOOLEAN—

Outputs (1)

NameTypeDescription
imageIMAGE—