Nodes/Transparency Background Remover/Remove Background & Resize
ComfyUI Node

Remove Background & Resize

Cut out and resize in one node, no OpenCV required

By Limbicnation·Created about a year ago·Updated 4 months ago· 22
Remove Background & Resize
  • image
  • image
  • mask
tolerance30
foreground_bias0.70
color_clusters8
output_sizeORIGINAL
scaling_methodLANCZOS
dither_handlingtrue
binary_threshold128

The pack has a quieter second member, and it's the one you might actually keep in every workflow. Remove Background & Resize combines a background cutout and a resize into a single node, and it's the only node in this pack that runs without OpenCV. Its k-means clustering is hand-rolled in plain numpy on top of Pillow - which means it also doesn't need scikit-learn. Where the flagship quietly loses its color clustering when sklearn is missing, this one just keeps working. Drop it into any ComfyUI and it functions. That's a genuinely nice resilience property.

Reach for it when you know the target size before you run. It's flagged as an output node in the source, so it behaves like a terminal step: "cut the background, deliver at exactly this size." The output_size choices give the intended use away - ORIGINAL, 512x512, 768x768, 1024x1024, 1280x720, 1920x1080. Those 16:9 options say product shots and page banners more than sprite sheets, and the default scaling_method is LANCZOS, the right call for photos.

The inputs that matter

  • tolerance (0-255) - colour distance threshold; higher is more aggressive extraction
  • foreground_bias - bias toward keeping pixels as foreground
  • color_clusters - k-means centre count for the colour segmentation
  • output_size and scaling_method (NEAREST for pixel-perfect, LANCZOS for photos)
  • dither_handling - edge erosion to suppress dither artefacts (note: different meaning than the flagship's dither detection)
  • binary_threshold - alpha mask binarisation cutoff

Two outputs: image and mask, same as the rest of the pack.

Where it fits

It's the same technique family as the flagship - a solid subject on a contrasting background - so the same limits apply: don't feed it a head of curly hair and expect magic. What it trades away is the flagship's content-aware switching: there's no edge_detection_mode, no auto_adjust, no pixel-art/photo pipeline choice, and no RGBA-vs-separate-mask option; you get a cutout and its mask at the size you asked for. If your subject's edges are the whole point, use the flagship and resize separately. If you just need clean, correctly-sized cutouts fast, this is the one you'll actually reach for.

Install

Same pack, same story - ComfyUI Manager, search "Transparency Background Remover", or:

cd ComfyUI/custom_nodes
git clone https://github.com/Limbicnation/ComfyUI-TransparencyBackgroundRemover.git
cd ComfyUI-TransparencyBackgroundRemover
pip install -r requirements.txt

Restart ComfyUI. The one thing to know: this node's dependencies are so light that even in a broken install (no sklearn, no OpenCV) it still runs, which makes it a decent canary - if this node loads, your install is fine and any other failure is in the heavier nodes.

Categoryimage/processing

Inputs (8)

NameTypeDefaultDescription
imageIMAGEInput image tensor from upstream node
toleranceINT300–255Colour distance threshold. Higher = more aggressive foreground extraction (0-255).
foreground_biasFLOAT0.700–1Bias toward keeping pixels as foreground. Higher = more pixels preserved.
color_clustersINT82–20Number of k-means centres for colour segmentation.
output_sizeCOMBOORIGINALResize output to this size. ORIGINAL keeps source dimensions.
scaling_methodCOMBOLANCZOSInterpolation method. LANCZOS = best quality; NEAREST = pixel-perfect for pixel art.
dither_handlingoptBOOLEANtrueApply edge erosion to suppress dither artefacts.
binary_thresholdoptINT1280–255Alpha mask binarisation cutoff (0-255).

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK