PD:Image centerCrop
Image centerCrop — the crop where W and H mean 'how much to shave', not target size
- image
- Result
Read the knobs before you touch this one, because W and H mean the opposite of what you'll assume. PD:Image centerCrop doesn't crop to a target width and height - it crops off an amount from each side. W=20 removes 20 pixels from the left and 20 from the right; H=10 removes 10 from the top and 10 from the bottom. The output keeps the center of the frame, symmetrically trimmed.
That's the whole point, and honestly it's a useful primitive that core ComfyUI doesn't give you directly. Strip a black bar off the top and bottom of a widescreen grab, cut a watermark row off the top of every frame in a batch, or just trim the edges of a scan - it's the "Photoshop crop with equal margins" move, and because it slices a tensor instead of re-sampling, it's instant and lossless.
How it works
Under the hood it's a plain tensor slice: x = W, y = H, then it keeps img_width - 2*W wide by img_height - 2*H tall from that offset. That's the whole mechanism - no resampling, no interpolation, just a crop. The defaults are both 0, which means the image passes through unchanged, so you can wire it into a graph as a no-op and dial in the trim without re-cabling.
The inputs that matter
- image (
IMAGE) - what you're trimming. - W (
INT, default 0) - pixels removed from the left and right combined per side. - H (
INT, default 0) - pixels removed from the top and bottom.
One output: Result (IMAGE), the center-cropped tensor, ready to go to a VAE decode, a saver, or back into a latent pipeline. Because it's a pure image-to-image node it slots anywhere an image feeds.
The trap
The error handling is honest but stern: W must be less than half the image width (same for H vs. height), or the node raises a ValueError and the run dies. If you feed it a batch where the images are different sizes - which ComfyUI doesn't really allow anyway - the math is done off the batch's shared dims, so it's safe there. The real footgun is assuming W/H are the desired output size and watching everything come back slightly wrong. If you want "crop to 1024×1024," that's PD:Image Crop_custom or PDImageResizeV2's fit: crop - not this node.
Also note there's no mask input here. If you need the crop applied to a mask in lockstep, the pack's PDimage_corp_v1/_v2 and PDImageCropLocation_V2 all carry masks along; this one is image-only.
Install
ComfyUI Manager: search PDuse (repo 7BEII/Comfyui_PDuse), install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt
Restart ComfyUI; the node shows as PD:Image centerCrop under PDuse/Image.
It's a one-job node, but it's the right node for that job. Every time I've needed symmetric edge-trimming in a batch, this has been the thing I reach for.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| W | INT | 00–10000000 | — |
| H | INT | 00–10000000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Result | IMAGE | — |