Nodes/ComfyUI-ConstrainResolution/Constrain Resolution
ComfyUI Node

Constrain Resolution

Intelligently resizes images to fit within resolution constraints while preserving aspect ratio. Perfect for preparing images for AI models with specific dimension requirements. 💡 USAGE TIPS: • Use 'Prioritize Min Resolution' to ensure images are never too small (may exceed max on one dimension) • Use 'Prioritize Max Resolution (Strict)' for hard VRAM limits (may go below min on one dimension) • Set 'Multiple Of' to 2 for most models, or higher values (8, 16, 32, 64) for optimal performance • 'lanczos' or 'bicubic' resize methods give the sharpest results; 'bilinear' is the fastest • 'Crop as Required' is enabled by default for immediate compatibility with strict dimension requirements • The node outputs both the resized image and the original for workflow flexibility

By EnragedAntelope·Created 2 years ago·Updated about 7 hours ago· 11
Constrain Resolution
  • image
  • resized_image
  • original_image
  • width
  • height
  • final_aspect_ratio
  • original_aspect_ratio
min_res704
max_res1280
multiple_of2
resize_methodlanczos
constraint_modePrioritize Min Resolution
crop_as_requiredtrue
crop_positioncenter
Categoryimage/resolution

Inputs (8)

NameTypeDefaultDescription
imageIMAGEInput image to analyze and resize
min_resINT7041–65536Minimum resolution in pixels for width and height. Images smaller than this will be upscaled.
max_resINT12801–65536Maximum resolution in pixels for width and height. Images larger than this will be downscaled.
multiple_ofINT21–256Ensures output dimensions are multiples of this number. Common values: 2 (most models), 8, 16, 32, or 64 (optimal performance). Set to 1 to disable rounding.
resize_methodCOMBOlanczosInterpolation method used when resizing. • lanczos: Sharpest results, best overall quality (default) • bicubic: High quality, slightly softer than lanczos • bilinear: Fast, slightly soft • nearest-exact: No interpolation — for pixel art or masks • area: Good for large downscales
constraint_modeCOMBOPrioritize Min ResolutionHow to handle conflicts when extreme aspect ratios make it impossible to satisfy both min and max. • Prioritize Min Resolution: Ensures neither dimension falls below min_res (may exceed max_res) • Prioritize Max Resolution (Strict): Strictly enforces max_res limit (may go below min_res)
crop_as_requiredBOOLEANtrueEnable cropping to achieve exact target dimensions when rounding causes aspect ratio changes. Disable if preserving the entire image is more important than exact dimensions.
crop_positionCOMBOcenterWhere to crop from when 'Crop as Required' is enabled. • center: Crop equally from all sides • top: Keep top portion, crop from bottom • bottom: Keep bottom portion, crop from top • left: Keep left portion, crop from right • right: Keep right portion, crop from left

Outputs (6)

NameTypeDescription
resized_imageIMAGEImage resized to the constrained dimensions
original_imageIMAGEOriginal image passed through unchanged for workflow flexibility
widthINTFinal width after constraints and rounding
heightINTFinal height after constraints and rounding
final_aspect_ratioFLOATAspect ratio of the output image (width/height)
original_aspect_ratioFLOATAspect ratio of the input image for comparison