ComfyUI_Image_Dimension_Scaler
Scale image dimensions while preserving aspect ratio, with pixel alignment and optional size constraints.
Nodes (1)
ComfyUI Image Dimension Scaler
A ComfyUI custom node that takes an image input and outputs scaled width/height dimensions while preserving the original aspect ratio.
Features
- Aspect ratio preservation: Output dimensions always match the input image's aspect ratio
- Pixel alignment: Round output dimensions to a multiple of 4, 8, 16, 32, or 64
- Largest dimension cap: Optionally limit the largest dimension (default: 1280)
- Total pixel limit: Constrain total pixels to a square budget (e.g., 1024 means max 1024x1024 = ~1M pixels)
- Dual output: Both integer (aligned) and float (exact) variants of width and height
Inputs
| Input | Type | Default | Description |
|-------|------|---------|-------------|
| image | Image | - | Input image to measure dimensions from |
| pixel_alignment | Combo | 8 | Round output dimensions to this multiple (4/8/16/32/64) |
| max_pixels_side | Int | 1024 | Max total pixels = value squared (e.g., 1024 = 1,048,576 max pixels) |
| limit_largest_dim | Boolean | true | Enable/disable the largest dimension cap |
| largest_dim_cap | Int | 1280 | Maximum value for the largest dimension |
Outputs
| Output | Type | Description |
|--------|------|-------------|
| width | Int | Step-aligned width |
| height | Int | Step-aligned height |
| width_float | Float | Exact scaled width (before alignment) |
| height_float | Float | Exact scaled height (before alignment) |
Installation
- Clone this repository into
ComfyUI/custom_nodes/ComfyUI_Image_Dimension_Scaler/ - Restart ComfyUI
Examples
- 1920x1080 with align=8, max_pixels=1024, limit=1280:
1280x720(921,600 pixels) - 3840x2160 with align=16, max_pixels=768, limit=2048:
1024x576(589,824 pixels) - 512x512 with align=64, max_pixels=1024, limit=1280:
512x512(no scaling needed)