Nodes/ComfyUI-Apt_Preset/Image_crop_visual
ComfyUI Node

Image_crop_visual

Drag-and-zoom cropping right on the node

By cardenluo·Created 2 years ago·Updated 22 days ago· 309
Image_crop_visual
  • image
  • cropped_image
crop_width512
crop_height512
fillnone
margin0
crop_state{"cx":0.5,"cy":0.5,"zoom":1.0}
crop_byScaletrue

Most crop nodes make you type x, y, width, and height and hope. Image_crop_visual instead draws an actual crop box over your image, on the node itself - per the pack's own description, you scroll the mouse wheel to zoom the box and drag to reposition it, and what you see is what gets cropped.

How it works

crop_width and crop_height (both default 512) set the exact output pixel dimensions - always, regardless of how big or small the on-screen box looks. crop_state is a small JSON string ({"cx":0.5,"cy":0.5,"zoom":1.0}) holding where the crop box currently sits - center position as a fraction of the image, plus zoom. You don't normally hand-edit it; the on-canvas widget writes it as you interact, and it's saved with your workflow so the crop position survives a reload. crop_byScale (default true) governs how that stored position/zoom gets reinterpreted. fill (none/white/black/grey/edge) decides what fills any part of the crop box that extends past the image's own edge, and margin adds a uniform pixel border around the crop before that fill applies.

The inputs and outputs that matter

  • image (required).
  • crop_width/crop_height (default 512 each) - the hard output size, independent of the visual box's on-screen shape.
  • crop_state - the drag/zoom-driven position, stored as JSON.
  • fill (default "none") and margin - how the node handles a crop box that hangs off the image edge.
  • Output: cropped_image. is_output_node is true, so it previews inline without a separate Preview Image node.

How to install it

Via ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git

Windows: install.bat. Linux/Mac: pip install -r ComfyUI-Apt_Preset/requirements.txt in your venv. Restart. Nothing to download for a crop tool - the pack's heavier dependencies belong to other parts of this actively maintained, ~300-star pack.

Common issues & troubleshooting

Crops look stretched or squashed. crop_width/crop_height are the real output size no matter what the visual box's on-screen proportions suggest. If a crop looks distorted, that's a mismatch between the box's displayed aspect and the numeric fields' actual ratio - adjust crop_width/crop_height to match what you want rather than trusting the drag handles alone.

Flat color bleeding into a crop. That's fill doing its job because your crop box extends past the image edge. Either move the box fully inside the frame, or switch fill to "edge" to stretch the border pixels instead of padding with a flat color if you want to avoid an obvious seam.

Crop position not surviving a reload. It should, since crop_state is saved as part of the node's widget state - if it resets, check you actually interacted with the on-canvas box (rather than just changing crop_width/crop_height) before saving, since the position/zoom only get written when the widget itself is used.

CategoryApt_Preset/image/visualize_edit

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
crop_widthINT5121–8192
crop_heightINT5121–8192
fillCOMBOnone5 options: none, white, black, grey, edge
marginINT00–500
crop_stateSTRING{"cx":0.5,"cy":0.5,"zoom":1.0}
crop_byScaleBOOLEANtrue

Outputs (1)

NameTypeDescription
cropped_imageIMAGE