Nodes/ComfyUI_Swwan/Image Resize By Megapixels (Swwan)
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

By aining2022·Created 9 months ago·Updated about a month ago· 27
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)

NameTypeDefaultDescription
imageIMAGE
megapixelsFLOAT1.000–100Target megapixels (1.0 = 1 million pixels). Use 0 to skip resize and keep the original size.
aspect_ratioCOMBOdefaultTarget aspect ratio. 'default' keeps original ratio.
keep_proportionCOMBOcropHow to handle aspect ratio change when not using 'default'.
divisible_byCOMBO16Width and height will be divisible by this value.
default_divisibleBOOLEANfalseWhen enabled, ensures final output dimensions strictly follow divisible_by constraint.
upscale_methodCOMBObilinear5 options: nearest-exact, bilinear, area, bicubic, lanczos
crop_positionCOMBOcenter5 options: center, top, bottom, left, right
pad_colorSTRING0, 0, 0Color to use for padding.
maskoptMASK
deviceoptCOMBO2 options: cpu, gpu

Outputs (5)

NameTypeDescription
IMAGEIMAGE
widthINT
heightINT
maskMASK
longest_edgeINT