CropImage_AS
A no-frills pixel crop that just works
- image
- IMAGE
CropImage_AS is exactly what it says on the tin: feed it an image, tell it where to crop and how big, get the cropped image back. No auto-detection, no aspect-ratio magic, no AI guessing - just a plain pixel rectangle. In a world where every image node wants to be clever, that's kind of refreshing.
It's from flyingshutter's As_ComfyUI_CustomNodes pack, a personal toolkit the author describes as a playground ("nothing is guaranteed to work"), so expect minimal polish and a working core. The one bit of polish worth knowing: the pack has zero extra dependencies. It runs on the torch and PIL that ComfyUI already ships, so you're not installing a wheelhouse to get a crop.
How it works
The mechanism is a single tensor slice, and I mean that literally - the whole node is image[:, y:y+height, x:x+width]. It cuts a rectangle out of your image, keeps the batch dimension intact, and hands back an IMAGE tensor. No resizing, no interpolation, no rounding to nice multiples. What you ask for is what you get, down to the pixel.
The inputs that matter
image- theIMAGEyou're cropping. Wire up whatever you're cutting from.x,y- the top-left corner of the crop, in pixels, counting from 0.width,height- how big the crop is.
All four numbers are plain integers with a max of 8192. That's it. One input, four ints, one output.
Where you'd actually reach for it
Crop is a staple of detail passes and region work. Common pattern: generate a full image, crop a face or an object down to a smaller rectangle, run a focused img2img or detailer pass on just that area, then composite it back. For that last step you'll usually want a mask-based blend rather than a paste - the sibling ImageMixMasked_As node in this same pack does exactly that, and MaskToImage_AS/ImageToMask_AS cover the round-trip. Or keep it simpler: crop a region to eyeball it at higher effective resolution before deciding what to regenerate.
Installing it
This is a git clone into custom_nodes and you're done - there's no requirements.txt to install because there's nothing to install:
cd ComfyUI/custom_nodes
git clone https://github.com/flyingshutter/As_ComfyUI_CustomNodes
Restart ComfyUI, and CropImage_AS appears under the ASNodes menu. If you use ComfyUI Manager, search for "As_ComfyUI_CustomNodes" and install from there - same result.
Common issues
The one real footgun: this crop doesn't clamp or validate. If x + width runs past the edge of the image, Python slicing silently hands you a smaller crop instead of an error. You won't get a crash, you'll get a 400px image when you asked for 512 - which then flows downstream and confuses everything it touches. If your output dimensions look wrong, check that your crop rectangle actually fits inside the source. The node also prints the image shape to the console on every run (print(image.shape)), which is noisy but useful for exactly this diagnosis.
For a 30-second tool, that's the whole story. If you need crops that snap to aspect ratios or auto-detect subjects, look elsewhere; if you need a rectangle cut out of an image, this does it with zero fuss.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 00–8192 | — |
| height | INT | 00–8192 | — |
| x | INT | 00–8192 | — |
| y | INT | 00–8192 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |