Skip to main content

Resize Image v2

KJNodes/image
ImageResizeKJv2

Resizes the image to the specified width and height. Size can be retrieved from the input. Keep proportions keeps the aspect ratio of the image, by highest dimension.

Example

JSON Example
{
  "class_type": "ImageResizeKJv2",
  "inputs": {
    "image": [
      "node_id",
      0
    ],
    "width": 512,
    "height": 512,
    "upscale_method": "nearest-exact",
    "keep_proportion": "stretch",
    "pad_color": "0, 0, 0",
    "crop_position": "center",
    "divisible_by": 2
  }
}

This example shows required inputs only. Connection values like ["node_id", 0] should reference actual node IDs from your workflow.

Inputs

NameTypeStatusConstraintsDefault
imageIMAGErequired--
widthINTrequiredmin: 0, max: 16384, step: 1512
heightINTrequiredmin: 0, max: 16384, step: 1512
upscale_methodENUM
5 options
  • nearest-exact
  • bilinear
  • area
  • bicubic
  • lanczos
required--
keep_proportionENUM
8 options
  • stretch
  • resize
  • pad
  • pad_edge
  • pad_edge_pixel
  • crop
  • pillarbox_blur
  • total_pixels
required-false
pad_color?STRINGrequired-"0, 0, 0"
crop_positionENUM
5 options
  • center
  • top
  • bottom
  • left
  • right
required-"center"
divisible_byINTrequiredmin: 0, max: 512, step: 12
maskMASKoptional--
deviceENUM
2 options
  • cpu
  • gpu
optional--

Outputs

IndexNameTypeIs ListConnection Reference
0IMAGEIMAGENo["{node_id}", 0]
1widthINTNo["{node_id}", 1]
2heightINTNo["{node_id}", 2]
3maskMASKNo["{node_id}", 3]
How to connect to these outputs

To connect another node's input to an output from this node, use the connection reference format:

["node_id", output_index]

Where node_id is the ID of this ImageResizeKJv2 node in your workflow, and output_index is the index from the table above.

Example

If this node has ID "5" in your workflow:

  • IMAGE (IMAGE): ["5", 0]
  • width (INT): ["5", 1]
  • height (INT): ["5", 2]
Was this page helpful?