PD:Image Crop_custom
Image Crop_custom — pixel-exact edge crops that carry the mask along
- image
- mask
- cropped_image
- cropped_mask
PD:Image Crop_custom is the pixel-number cousin of the pack's PD:Image Crop_ratio. Where the ratio version takes a fraction, this one takes an exact size: crop a 512-pixel strip off the left edge, keep a 256-pixel band from the bottom, that kind of thing. Same family, same design - pick one edge, cut a fixed-width or fixed-height slice, and any connected mask gets cut identically.
The honest framing: it's a bare-bones strip cropper. If you want a centered crop to an exact size, that's PD:Image centerCrop or PDImageResizeV2's crop fit. This node is for when you know precisely which edge and how many pixels.
How it works
On the x-axis it computes crop_w = min(size_width, image_width) - so it clamps rather than errors if you ask for more than the image has - then slices from the chosen edge:
direction = leftkeeps[0 : crop_w]- the left portion survives.direction = rightkeeps[width - crop_w : width]- the right portion survives.
The y-axis is identical with size_height and top/bottom. The axis input decides which size applies: axis=x uses size_width, axis=y uses size_height. The other size field is ignored, which is worth remembering because both default to 512.
The inputs that matter
- image (
IMAGE) - source. - size_width (
INT, default 512) - width of the strip on the x-axis. - size_height (
INT, default 512) - height of the strip on the y-axis. - axis -
xory(defaultx). - direction -
left/right/top/bottom(defaultleft). - mask (
MASK, optional) - cropped in lockstep.
Outputs: cropped_image (IMAGE) and cropped_mask (MASK).
Where it earns its place
Tile workflows. If you're slicing a large image into fixed-size regions for upscaling or batch processing, an edge-based fixed-size crop is exactly the primitive you want in a loop - each step cuts a known pixel band off the remaining image. It's also the right tool for removing a fixed-width border on all sides of a scan, one edge per node.
The mask sync is the reason to pick it over core's ImageCrop in mask-sensitive pipelines. Wire Load Image.MASK into mask and you get the same region as a mask out, perfectly registered - no manual re-alignment when the crop feeds an inpaint or a compositor.
Two gotchas
First, if you don't touch the defaults you crop a 512×512 strip off the left edge of whatever you feed it - change size_width/size_height before running, or you'll wonder why your image shrank. Second, cropped_mask returns None when no mask is connected (it doesn't fabricate an all-white one - that's PDImageCropLocation_V2's behavior). So if the downstream node needs a mask unconditionally, connect one.
Install
ComfyUI Manager: search PDuse (repo 7BEII/Comfyui_PDuse), install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt
Restart and it shows as PD:Image Crop_custom under PDuse/Image. Thin, predictable, and exactly right for edge-strip jobs.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| size_width | INT | 5121–8192 | — |
| size_height | INT | 5121–8192 | — |
| axis | COMBO | x | 2 options: x, y |
| direction | COMBO | left | 4 options: left, right, top, bottom |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |
| cropped_mask | MASK | — |