PD Image Crop Location_V2
PD Image Crop Location_V2 — trim one edge by N pixels and get a matching mask for free
- image
- mask
- cropped_image
- cropped_mask
PDImageCropLocation_V2 is the edge-trimming cousin of the pack's coordinate crop, and it does two things the V1 doesn't: it crops from an edge rather than from arbitrary coordinates, and it hands back a mask that's guaranteed to line up - even manufacturing an all-white one when you don't provide any.
The workflow that makes this shine: "cut N pixels off the left side of every frame, and keep the mask in sync so my inpaint or composite doesn't drift." The author clearly built it for mask-bearing pipelines, and the mask handling is where the design decisions live.
How it works
x is the number of pixels removed, not kept - the most important thing to internalize. crop_direction says which edge gets shaved:
left→ keepsimage[:, :, x:](drops the leftxpixels)right→ keepsimage[:, :, :width-x]top→ keepsimage[:, x:, :, :]bottom→ keepsimage[:, :height-x, :, :]
No cropping happens to the other dimensions - it's a straight strip removal, so nothing gets resized or re-sampled. If x is bigger than the relevant dimension, it raises a ValueError rather than returning a degenerate crop.
The mask side is the interesting bit. If you connect a MASK, it gets the identical slice. If you don't, the node creates an all-white mask sized to the output. That second behavior is why you can wire the outputs straight into an inpaint or a ComfyUI-Inpaint-style node without ever thinking about mask alignment - the mask is always valid and always registered.
The inputs that matter
- image (
IMAGE) - source. - x (
INT, default 50) - pixels removed from the chosen edge. Default 50 means 50 pixels gone the moment you drop the node in. - crop_direction -
left/right/top/bottom(defaultleft). - mask (
MASK, optional) - cropped alongside; absent → all-white mask generated.
Outputs: cropped_image (IMAGE) and cropped_mask (MASK).
Real uses
Border removal is the classic: scans and screenshots with uneven edges get a fixed strip taken off cleanly, in a batch, deterministically. Watermark or black-bar trimming off one edge is a one-node job. And in a masking pipeline, the free all-white mask is genuinely handy - you can chain the output into a mask-based blend without a separate "create solid mask" node.
Gotchas
Remember x = amount removed. The default of 50 will visibly shave your image the first run, which is fine once you know it - but it's easy to misread as "keep 50px." Also, unlike the pack's ratio/custom crops, this one has no axis choice: horizontal directions (left/right) always apply to width, vertical to height. And the generated mask when none is supplied is all-white, which in a mask-is-foreground convention means "everything kept" - if your downstream treats white as cut, flip it.
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 Location_V2 under PDuse/Image. Edge trims plus free masks - the most useful crop variant in this pack for compositing work.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| x | INT | 500–4096 | — |
| crop_direction | COMBO | left | 4 options: left, right, top, bottom |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |
| cropped_mask | MASK | — |