Nodes/ComfyUI-Light-Tool/Light-Tool: Crop Image
ComfyUI Node

Light-Tool: Crop Image

Cut N pixels off each edge

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: Crop Image
  • image
  • image
left_margin100
top_margin100
right_margin100
bottom_margin100

Light-Tool: CropImage cuts a border off each edge of your image: so many pixels from the left, so many from the top, right, and bottom. It's the "trim the frame" node - you know you want to chop off the edges, and you know roughly how many pixels each side should lose.

The margin-based mental model is genuinely more useful than it sounds. Cropping by coordinates requires you to know the image dimensions; cropping by margins doesn't. "Take 100px off every side" works identically on a 512×512 and a 2048×2048 image, which makes it perfect for batch work where sizes vary. It's the natural complement to the pack's margin-padding nodes: pad with AddBackgroundV2, then trim back with this one, and your effective margins stay exact.

How it works

The four inputs are straightforward pixel counts:

  • left_margin, top_margin, right_margin, bottom_margin - how much to remove from each edge, all defaulting to 100.

The node computes left = left_margin, right = width - right_margin, top = top_margin, bottom = height - bottom_margin, and crops to that box. So a 512×512 image with the defaults keeps the central 312×312.

The one real failure mode is up front: if your margins overlap (say, left_margin of 300 and right_margin of 300 on a 512-wide image), the node throws a clear ValueError telling you the crop region is invalid. The error message is genuinely helpful - it tells you to check whether your left/right or top/bottom margins are too large - so you won't be stuck guessing. Still, it's worth knowing it's a hard error rather than a clamp: margin sums that exceed the image dimension break the run, so if your image sizes vary, don't set margins that could add up to more than the smallest one.

Inputs and output

image in, image out. Batch behavior is worth flagging: the crop operates on the image as a whole, not per-frame. If you're cropping a batch of images all the same size, no problem. If the frames differ in size, the crop math still applies per image (each computes from its own dimensions), but any frame whose margins overlap its own size will error - keep sizes consistent and you're fine.

The honest comparison

For fixed coordinates you'd use a coordinate crop node; for cropping to the content itself you'd use BoundingBoxCropping (transparent-subject auto-crop). This node is specifically the "I want to shave a border off" tool. If you want to crop to a multiple of 64 from the center for VAE compatibility, the pack also ships Safe Image Crop (Light-Tool: SafeImageCrop) which is the one to grab for latent-safe sizing - a genuinely better default than guessing margins when VAE constraints matter.

Install

Standard: ComfyUI Manager → search ComfyUI-Light-Tool, or clone into custom_nodes, pip install -r requirements.txt, restart. It's under ComfyUI-Light-Tool → image → Crop. No models, no extra dependencies.

CategoryComfyUI-Light-Tool/image/Crop

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
left_marginINT100
top_marginINT100
right_marginINT100
bottom_marginINT100

Outputs (1)

NameTypeDescription
imageIMAGE