Nodes/BaiduMeux_Comfy Tools/Meux Advanced Image Crop
ComfyUI Node

Meux Advanced Image Crop

Crop by trimming edges, not drawing a box

By fchangjun·Created about a year ago·Updated 5 months ago· 4
Meux Advanced Image Crop
  • image
  • IMAGE
measurementPixels
align_to8
left0
right0
top0
bottom0

Most crop tools in ComfyUI ask you to define a box: x, y, width, height. MeuxAdvancedImageCrop thinks in insets instead - how much to shave off the left, right, top and bottom. That's a much better mental model for the two things people actually do with crops: trimming borders off generated images, and shaving a fixed percentage off every edge to get a uniform result. If you've ever wanted "cut 10% off all sides, then snap the result to a clean grid," this node is exactly that, and nothing more.

How it works

It's a thin slice of tensor slicing with two conveniences layered on. measurement switches the four inset values between Pixels and Percentage. In percentage mode, each value is converted against the corresponding dimension (left/right against width, top/bottom against height), which gives you resolution-independent crops - handy when you're processing a batch of differently-sized images.

The second convenience is align_to: 0, 8, or 16. When set, the four insets get snapped down to that grid (an 8px grid turns a 10px inset into 8px) so the cropped region's coordinates stay aligned. That matters if you're feeding the result into an upscale or outpaint chain where misaligned edges produce visible seams, or into a sampler that prefers dimensions on an 8 or 16 boundary.

Two guardrails are worth knowing. If all four insets are zero, the node returns the image untouched instead of erroring. And if the insets overlap - left inset lands at or beyond the right edge - you get a clear "Invalid crop" error rather than a silent empty tensor.

Inputs and outputs

The four numbers are the whole job:

  • measurement - Pixels or Percentage
  • align_to - 0, 8, or 16
  • left, right, top, bottom - how much to trim from each edge (in pixels or percent)

One output, IMAGE, cropped. Note it's image-only: no mask, no bbox, no latent. If you need the crop region as geometry for other nodes, this isn't the tool - it's a straight transform.

Installing and the pack context

It comes from the BaiduMeux ComfyTools pack:

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

Restart ComfyUI, or install via ComfyUI Manager (search "Baidu Meux ComfyTools"). The shared requirements pull in the pack's heavier dependencies (transformers, torchvision, realesrgan, scipy) even though this node only needs numpy and torch - a known annoyance of the pack, and the standard custom-node version-conflict risk.

Troubleshooting

If the crop comes out smaller than you expected, check measurement first - a "10" in percentage mode on a 2048px image trims 205px, not 10px. If you see the "Invalid crop" error, your insets sum past the image dimension; drop one of them. And if the result looks slightly misaligned in your next node, remember align_to only snaps insets, so the final size is whatever the math leaves you with - pick 0 to disable snapping if you need the exact pixel-for-pixel crop.

CategoryImage/Transform

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
measurementCOMBOPixels2 options: Pixels, Percentage
align_toCOMBO83 options: 0, 8, 16
leftINT00–16384
rightINT00–16384
topINT00–16384
bottomINT00–16384

Outputs (1)

NameTypeDescription
IMAGEIMAGE