Nodes/Auto Crop By NPS/Auto Crop by NPS
ComfyUI Node

Auto Crop by NPS

The 'auto' is a lie, but this slider-driven crop/rotate node is still handy

By WX-NPS1598·Created 2 years ago·Updated 2 years ago· 5
Auto Crop by NPS
  • image
  • mask
  • image
  • mask
crop_top0.00
crop_bottom0.00
crop_left0.00
crop_right0.00
rotation0

Let's get the naming out of the way: there is nothing "auto" about Auto Crop by NPS. It won't find a face, detect a horizon, or crop to a subject. What it does - the whole thing, end to end - is hand you five sliders that crop, pad, and rotate an image. That's it, and for a surprising number of jobs that's exactly the tool you want.

The pitch: one node that can trim edges, extend the canvas with white padding, and rotate the image, all driven by sliders expressed as fractions of the image rather than pixel counts. Feed it a 512px image or a 2048px one and a 0.1 crop takes a proportional bite out of either. A step of 0.02 is 2% of the dimension, so on a 1024px image each click of the slider shaves about 20 pixels. That scale-independence is the genuinely nice property here.

How it works

The sign of each crop slider does double duty. Negative values crop: -0.25 on crop_left removes a quarter of the width from the left edge, and the same applies to top, bottom, and right. Positive values do the opposite - they expand the canvas in that direction, padding with solid white. Zero does nothing. The rotation slider spins the whole thing; a positive value rotates clockwise, negative counter-clockwise, and it always uses expand=True, so the canvas grows to fit the rotated content instead of clipping corners.

Two things to keep in mind. First, the padding and rotation fill are hardcoded to white - there's no fill-color option, so you're going to see white borders, not transparent or black ones. Second, when both image and mask are connected, the exact same crop, pad, and rotation are applied to both, which is the whole reason the node has a mask input at all: you keep a segmentation mask in lockstep with its image instead of having to re-derive it after a transform.

Inputs and outputs

The five sliders in the required block are everything you'll touch:

  • crop_top, crop_bottom, crop_left, crop_right - range -1 to 1, step 0.02. Negative crops, positive pads with white.
  • rotation - -180 to 180 degrees, step 1.

The optional inputs are image (IMAGE) and mask (MASK); connect whichever you're transforming - the node can take both or just one. It outputs image and mask, and the outputs wire straight into anything downstream that expects those types: a VAE encode, an inpaint-combine step, a save node. It also handles batched inputs, applying the same sliders to every image in the batch.

Installing it

The README suggests dropping a single .py file into custom_nodes, and current ComfyUI does load loose files there. The cleaner route is the whole repo, which keeps it updatable:

cd ComfyUI/custom_nodes
git clone https://github.com/WX-NPS1598/ComfyUI-Auto_Crop_By_NPS

Then restart ComfyUI, or install it through ComfyUI Manager by searching for "Auto Crop By NPS". No dependencies to babysit: the code only uses numpy, Pillow, and torch, all of which ComfyUI already ships. No model downloads, no API keys.

Where people get burned

The usual first trap is forgetting the sign convention - expecting a positive slider to crop and getting a white border instead. The other recurring gotcha is the white fill: if you're cropping outward to outpaint a composition, a white extension can be exactly what you want, but if you were hoping for transparency, this isn't the node for it.

Also note the outputs: if you only feed image, the mask output comes back as None, and vice versa. Don't wire the empty output into a node that demands a tensor. And while we're being honest about quality-of-life utilities, this is a tiny single-author pack with essentially no community footprint - the kind of node you install because you need a quick manual crop, not because the ecosystem raves about it. For that narrow job, it's refreshingly simple: five sliders, one result, no surprises.

CategoryNPS1598

Inputs (7)

NameTypeDefaultDescription
crop_topFLOAT0.00-1–1
crop_bottomFLOAT0.00-1–1
crop_leftFLOAT0.00-1–1
crop_rightFLOAT0.00-1–1
rotationFLOAT0-180–180
imageoptIMAGE
maskoptMASK

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK