Nodes/Comfyui-PixNodes/Image Crop Edge (PixNodes)
ComfyUI Node

Image Crop Edge (PixNodes)

Strip black bars and stray borders without leaving ComfyUI

By pixixai·Created 8 months ago·Updated 6 months ago· 24
Image Crop Edge (PixNodes)
  • image
  • IMAGE
crop_size0

Somewhere in every batch workflow there's an image with letterbox bars, a watermark strip, or a stray border from an earlier crop, and you need it gone before the next node sees it. Image Crop Edge is the smallest possible tool for that: it slices a fixed number of pixels off the edges and hands you the trimmed image back. No model, no dialog, no resizing - just a torch slice.

The name is honest about the mechanism. This is a pure tensor crop: it takes your [B, H, W, C] image tensor, cuts crop_size rows and columns off the edges, and returns the remainder. It's deterministic, it's instant, and it works on batches, so a whole folder of images with the same letterbox gets cleaned in one pass.

The one input that matters

There are two inputs: image (IMAGE) and crop_size (STRING, default "0"). The crop_size string is where the actual logic lives, and it's worth understanding because it has two forms:

  • One number - 10 crops 10 pixels off all four sides. This is the common case: symmetrical border, same answer everywhere.
  • Four numbers, comma-separated - 10,20,30,40 means top, bottom, left, right. For asymmetric cases like a video frame with bars on top and bottom only: 20,20,0,0.

The parser is forgiving: it splits on commas, strips whitespace, ignores anything that isn't an integer, and clamps negative values to zero. Give it garbage and you get a no-op, not a crash. Under the hood it also clamps each value to the image height/width so an oversized crop can't index out of bounds.

Wiring it in

Load Image → Pix_ImageCropEdge → (anything that wants IMAGE)

There's a single output, IMAGE, same shape minus the trimmed pixels. It slots cleanly before an upscaler, a tiler, or a VAE encode - anywhere a border would corrupt what comes next.

Install

Part of the Comfyui-PixNodes pack: ComfyUI Manager → search "PixNodes" → install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/pixixai/Comfyui-PixNodes

then restart. (Ignore the README's manual-install line that points at the wrong repo, ComfyUI-AlignLayout - use the URL above.) No models, no heavy deps.

Where it falls short

This node only removes pixels - there's no negative crop, no border expansion, no padding. If your goal is to add a border or center an image in a canvas, this isn't the tool. And because it's integer math with floor division, odd crop amounts can leave you a pixel off from where you'd expect; that never matters for trimming bars, but it will for precision work. For the everyday "kill the black bars" job, though, it's hard to beat a one-string interface.

CategoryPixNodes

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
crop_sizeSTRING0

Outputs (1)

NameTypeDescription
IMAGEIMAGE