Description
The Image Transform KJ node provides an interactive, in‑preview interface for cropping, resizing, padding, and rotating images (and optional masks).
Connect an image input and the preview appears automatically, allowing you to draw crop regions, adjust padding placement, and apply rotation directly in the preview.
Cropping:
- Click + drag to draw a crop region.
- Drag inside the region to move it; drag edges or corners to resize.
- Right‑click to delete a region.
- Hold Ctrl to snap to a grid.
- Hold Shift while resizing to constrain the aspect ratio.
- Hold Alt while resizing to resize symmetrically around the center.
Padding:
- Hold Shift and drag the content inside the preview to adjust the padding position (equivalent to changing
pad_xandpad_y).
Rotation:
- Click the Rotate button to enable a rotation cross. Drag to rotate; right‑click to reset rotation.
Inputs
| Name | Type | Default | Tooltip / Description |
|---|---|---|---|
image | IMAGE / MATCHTYPE | – | The image (or mask‑compatible tensor) to transform. |
mask | MASK | optional | Optional mask to transform alongside the image. |
target_width | INT | 0 | Target output width. 0 = keep original width. |
target_height | INT | 0 | Target output height. 0 = keep original height. |
upscale_method | COMBO | lanczos | Interpolation method for resizing: nearest-exact, bilinear, area, bicubic, lanczos. |
keep_proportion | DYNAMICCOMBO | – | Controls how the content fits the target dimensions (e.g. keep aspect ratio, stretch, etc.). Options depend on the backend – adjust to match your workflow. |
divisible_by | INT | 2 | Ensures output dimensions are divisible by this value (0 = no constraint; max 512). |
extra_padding | DYNAMICCOMBO | – | Enables additional padding around the cropped content. When active, pad_x, pad_y, and edge_mode are used. |
invert_crop | DYNAMICCOMBO | – | When enabled, the crop region is inverted (the area outside the crop is kept / processed). |
bboxes | STRING | "" | Optional pre‑existing bounding boxes (e.g. from a detection node) to be applied or modified. |
pad_x | FLOAT | 0.5 | Horizontal position of content inside the padded area (0 = left, 0.5 = center, 1 = right). Also adjustable interactively by Shift+dragging content. |
pad_y | FLOAT | 0.5 | Vertical position of content inside the padded area (0 = top, 0.5 = center, 1 = bottom). Also adjustable interactively by Shift+dragging content. |
edge_mode | COMBO | clamp | How to fill padding areas: clamp (extend edge pixels), repeat (tile the image), mirror (tile with mirroring). |
width_mult | FLOAT | 1.0 | Multiply the crop width by this factor. Range [0.01, 16], step 0.05. |
height_mult | FLOAT | 1.0 | Multiply the crop height by this factor. Range [0.01, 16], step 0.05. |
Note: The interactive preview updates in real time. Changes to pad_x, pad_y, width_mult, height_mult, and rotation are reflected immediately.
Outputs
| Output # | Type | Description |
|---|---|---|
| 1 | IMAGE (same type as input) | The transformed image after crop, resize, pad, and rotation. |
| 2 | MASK | The transformed mask (if a mask input was provided; otherwise an empty mask). |
| 3 | BBOX | Bounding box coordinates of the applied crop region (format depends on backend, typically [x1, y1, x2, y2] or similar). |
| 4 | MASK | A mask corresponding to the cropped region (useful for compositing or further processing). |
| 5 | INT | Width of the final crop region. |
| 6 | INT | Height of the final crop region. |
Usage Notes
- Interactive cropping is the intended primary workflow: the preview allows intuitive selection of crop regions. The
bboxesinput can be used to supply or override the region programmatically. - Resizing behavior: When both
target_widthandtarget_heightare 0, the output retains the cropped / padded size without additional upscaling. To resize to a specific resolution, set one or both targets and choose anupscale_method. Thekeep_proportionoption determines whether the image is stretched, cropped to fit, or padded to fill the target. - Padding is only applied when
extra_paddingis enabled. Usepad_x/pad_yto position the content, andedge_modeto control how the padding area is filled. - Rotation is applied after cropping and before resizing/padding. The rotation cross in the preview gives fine control; the rotation is stored internally and can be adjusted per‑session.
- The
divisible_byparameter is useful for aligning dimensions to model‑friendly sizes (e.g., multiples of 8, 16, 32). Setting it to 0 disables the constraint. - Coordinate snapping: Hold Ctrl while drawing or moving a crop rectangle to snap its position and size to a grid (grid spacing is determined by the node’s internal step). This helps align crops to a regular tiling.
All parameters that affect the final output are exposed as inputs, so the node can be used both interactively and in fully automated pipelines by connecting appropriate values (e.g., from other nodes that output bounding boxes or dimensions).
Comments
Sign in with GitHub to join the discussion.