ComfyUI Node
Image Resize By Megapixels (Swwan)
Resizes image to target megapixels with optional aspect ratio control. - megapixels: Target total pixels in millions (1.0 = 1,000,000 pixels). Use 0 to skip resizing. - aspect_ratio: 'default' keeps original ratio, or choose a specific ratio - keep_proportion: How to handle aspect ratio changes (crop, pad, resize, etc.) - divisible_by: Ensures output dimensions are divisible by this value - default_divisible: When enabled, strictly enforces divisible_by on final output
Image Resize By Megapixels (Swwan)
- image
- mask
- IMAGE
- width
- height
- mask
- longest_edge
◄megapixels1.00►
◄aspect_ratiodefault►
◄keep_proportioncrop►
◄divisible_by16►
◄default_divisiblefalse►
◄upscale_methodbilinear►
◄crop_positioncenter►
◄pad_color0, 0, 0►
◄device▾►
CategorySwwan/image
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| megapixels | FLOAT | 1.000–100 | Target megapixels (1.0 = 1 million pixels). Use 0 to skip resize and keep the original size. |
| aspect_ratio | COMBO | default | Target aspect ratio. 'default' keeps original ratio. |
| keep_proportion | COMBO | crop | How to handle aspect ratio change when not using 'default'. |
| divisible_by | COMBO | 16 | Width and height will be divisible by this value. |
| default_divisible | BOOLEAN | false | When enabled, ensures final output dimensions strictly follow divisible_by constraint. |
| upscale_method | COMBO | bilinear | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
| crop_position | COMBO | center | 5 options: center, top, bottom, left, right |
| pad_color | STRING | 0, 0, 0 | Color to use for padding. |
| maskopt | MASK | — | |
| deviceopt | COMBO | 2 options: cpu, gpu |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| width | INT | — |
| height | INT | — |
| mask | MASK | — |
| longest_edge | INT | — |