Visit ComfyUI Online for ready-to-use ComfyUI environment
Adjust image dimensions within specified constraints while maintaining aspect ratio, with optional cropping for size requirements.
The ConstrainImage| Constrain Image 🐍 node is designed to adjust the dimensions of an image to fit within specified maximum and minimum width and height constraints while maintaining the original aspect ratio. This node is particularly useful for ensuring that images conform to specific size requirements without distorting their proportions. By setting boundaries for the image dimensions, you can ensure consistency and compatibility across various applications, such as web design, digital art, and multimedia projects. The node also offers an option to crop the image if necessary to meet the size constraints, providing flexibility in how the image is adjusted.
This parameter accepts the image or images that you want to constrain. The input should be in the format of an image file. The node processes each image individually to ensure they meet the specified size constraints.
This parameter sets the maximum allowable width for the image. The default value is 1024 pixels, and it must be a non-negative integer. If the image's width exceeds this value, it will be scaled down proportionally to fit within this limit while maintaining the aspect ratio.
This parameter sets the maximum allowable height for the image. The default value is 1024 pixels, and it must be a non-negative integer. If the image's height exceeds this value, it will be scaled down proportionally to fit within this limit while maintaining the aspect ratio.
This parameter sets the minimum allowable width for the image. The default value is 0 pixels, and it must be a non-negative integer. If the image's width is less than this value, it will be scaled up proportionally to meet this minimum requirement while maintaining the aspect ratio.
This parameter sets the minimum allowable height for the image. The default value is 0 pixels, and it must be a non-negative integer. If the image's height is less than this value, it will be scaled up proportionally to meet this minimum requirement while maintaining the aspect ratio.
This parameter determines whether the image should be cropped if it cannot meet the size constraints through scaling alone. The options are "yes" or "no," with the default being "no." If set to "yes," the image will be cropped to fit within the specified dimensions if necessary.
The output is the adjusted image that meets the specified size constraints. The image will have been scaled and/or cropped as necessary to fit within the maximum and minimum width and height parameters while maintaining the original aspect ratio. This ensures that the image is optimized for your specific requirements without distortion.
crop_if_required
parameter to "yes" to allow cropping when scaling alone is insufficient.crop_if_required
option to allow the image to be cropped to fit within the specified dimensions.© Copyright 2024 RunComfy. All Rights Reserved.