Nodes/PortraitUtils/Smart Photo Prepare
ComfyUI Node

Smart Photo Prepare

Prepare a photo for the selected editor with a native source crop and one typed diagnostics output.

By heyburns·Created 12 months ago·Updated 3 days ago· 2
Smart Photo Prepare
  • image
  • editor_target
  • crop_config
  • mask
  • protected_region_mask
  • prepared_image
  • native_crop
  • prepared_mask
  • prepare_info
◄resize_methodbicubic►
◄invert_maskauto►
◄q_left0.005►
◄q_right0.995►
◄q_top0.005►
◄q_bottom0.995►
◄min_span_px8►
◄headroom_ratio0.12►
◄footroom_ratio0.06►
◄side_margin_ratio0.08►
◄bottom_priority0.75►
◄horiz_gravitycenter►
◄framing_tolerance_percent0.5►
◄crop_tolerance_px4►
◄profilefalse►
CategoryPortraitUtils/Photo Edit V2

Inputs (20)

NameTypeDefaultDescription
imageIMAGE—
editor_targetPORTRAIT_EDITOR_TARGET—
crop_configPORTRAIT_CROP_CONFIG_V2—
resize_methodCOMBObicubic4 options: bicubic, lanczos, area, bilinear
invert_maskCOMBOauto3 options: auto, false, true
q_leftFLOAT0.0050–0.2—
q_rightFLOAT0.9950.8–1—
q_topFLOAT0.0050–0.2—
q_bottomFLOAT0.9950.8–1—
min_span_pxINT81–2048—
headroom_ratioFLOAT0.120–0.45—
footroom_ratioFLOAT0.060–0.45—
side_margin_ratioFLOAT0.080–0.45—
bottom_priorityFLOAT0.750–1—
horiz_gravityCOMBOcenter3 options: center, left, right
framing_tolerance_percentFLOAT0.50–10Allows similarly framed safe crops to compete on resize quality; fallback pixel counts take priority.
crop_tolerance_pxoptINT40–64When no safe crop fits, allow at most this many source pixels per edge into available safety margins. 0 always preserves them. The protected-region mask stays intact.
maskoptMASK—
protected_region_maskoptMASKConnected critical-region masks are protected in every crop mode, including Auto aspect with Smart Crop off.
profileoptBOOLEANfalseRecord host stage timings in info. No CUDA synchronization or model-memory changes.

Outputs (4)

NameTypeDescription
prepared_imageIMAGE—
native_cropIMAGE—
prepared_maskMASK—
prepare_infoPORTRAIT_PREPARATION_INFO_V2—