Nodes/NN-custom-nodes/Image Inset Crop
ComfyUI Node

Image Inset Crop

Crop by percentage, not by pixel math

By bandifiu·Created about a month ago·Updated about a month ago· 0
Image Inset Crop
  • image
  • image
top0.0
left0.0
right0.0
bottom0.0
enablefalse

Cropping in ComfyUI is usually a pixel count: crop 200 from the left, 300 from the top. That's great until you're processing images of wildly different sizes and want the same relative crop on all of them - trim 10% off each side, no matter whether the source is 512×512 or 2048×1024. "Image Inset Crop" does exactly that, and it does it by percentage.

What it is

NNImageInsetCropPercent crops an image from all four sides, where each crop amount is a percentage of the image's width or height rather than a fixed pixel count. The README's summary is right there: "Percentage-based cropping, supports image batches, keeps crop positioning predictable." If you've ever wanted "chop 5% off the top and 10% off the left" applied uniformly across a whole batch, this is the node.

How it works

The source shows the whole story. Each side's value is a percentage of the corresponding dimension - left and right are percent of width, top and bottom are percent of height - and it's rounded so the crop lands on clean pixel boundaries. Then the four insets are applied and the frame is sliced. A few behaviors worth noting:

  • The enable toggle - default off. Until you flip it, the node passes the image through untouched. That's deliberate: you can park the node in a workflow with your crop percentages pre-dialed, and turn the crop on and off without losing your settings. Plenty of people get confused on first contact because the node seems to do nothing - check enable.
  • Batch support - every frame in the batch gets the same percentage crop, so a video or image sequence stays spatially consistent.
  • Error handling - if your percentages overlap (top+bottom > 100), the node raises a clear error instead of silently producing a zero-size or flipped crop.

The inputs

  • image - the tensor to crop.
  • top / left / right / bottom - each 0–99.9, default 0. Percent of height/width to remove from that side. A symmetric crop for a tighter composition: top 10, left 10, right 10, bottom 10.
  • enable - the master switch, default off.

Single image output, same batch count, smaller frames.

When to reach for it

The killer use case is normalizing differently-sized inputs into the same relative framing - say you're about to feed a mixed-resolution batch into a detailer or an upscaler that behaves better on a consistent composition. Percent-based cropping is also the right tool when you're mimicking a look (crop every output the way a particular style guide crops) or when you're building a workflow you'll reuse on unknown input sizes, where a fixed pixel crop would be wrong on the next image.

The trade-off is the flip side of its strength: it's not for precision edits. If you need "crop to exactly 512×512 starting at x=40, y=60," that's a pixel-crop node's job, not this one. This node answers "same relative crop everywhere," which is a genuinely different question.

Installing

Ships in bandifiu/ComfyUI-NN-custom-nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/bandifiu/ComfyUI-NN-custom-nodes

Restart ComfyUI (or Manager → "NN-custom-nodes"). Deps: torch, numpy, pillow - no models. GPL-3.0, V3 backend API, no classic NODE_CLASS_MAPPINGS.

The one real trap: percentages accumulate. Crop 10% off the top and 10% off the bottom removes 20% of the height total, which feels like more than you asked for if you're used to thinking "crop 10%" as one action. Think in terms of "what fraction of the frame should stay," and you'll set sane values.

CategoryNN/image

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
topFLOAT0.00–99.9
leftFLOAT0.00–99.9
rightFLOAT0.00–99.9
bottomFLOAT0.00–99.9
enableBOOLEANfalse

Outputs (1)

NameTypeDescription
imageIMAGE