Nodes/ControlFlowUtils/πŸŒ„ Image Resolution Adjust
ComfyUI Node

πŸŒ„ Image Resolution Adjust

This node receives a given image size Source_Width and Source_Height and performs calculations to automatically resize the image based either on a given Scaling_Factor or towards a specific Target_Width and Target_Height. If the Scaling Factor is used the image's aspect ratio will be adjusted directly. If the value is > 1, the image's width will be multiplied by the Scaling_Factor. If the value is < 1 the image's height will be changed instead. If either Target_Width and Target_Height (but not both) are specified, the image final size will be adjusted to be rescaled to the target, while still attempting to maintain the closest possible approximation to the original Aspect Ratio. The aggressiveness of this approximation is determined by the value of Tolerance, which will make sure the final sizes are always multiples of Tolerance. If Both are specified (such that they are the same to each other or identical to the Source values), the Adjusted Width and Height will be returned immediately, as no further calculation is required. For the most part the default values work well, and you should specify either a Target_Width or Target_Height to obtain the desired effect, although Scaling_Factor can also be useful in certain situations. HOVER OVER THE INPUTS AND OUTPUTS FOR MORE INFO.

By VykosXΒ·Created 2 years agoΒ·Updated 2 years agoΒ· 147
πŸŒ„ Image Resolution Adjust
    • Adj. Width
    • Adj. Height
    • Result
    β—„source_width512β–Ί
    β—„source_height512β–Ί
    β—„scaling_factor1.0β–Ί
    β—„target_width512β–Ί
    β—„target_height512β–Ί
    β—„tolerance32β–Ί
    Category🐺 VykosX-ControlFlowUtils

    Inputs (6)

    NameTypeDefaultDescription
    source_widthINT51216–8192The original width of the image to adjust
    source_heightINT51216–8192The original height of the image to adjust
    scaling_factorFLOAT1.00.1–10The scaling factor to multiply the image's dimensions by. > 1 values affect image width and < 1 values affect image height
    target_widthINT51216–8192The new target width of the image where the new height can be automatically extrapolated from
    target_heightINT51216–8192The new target height of the image where the new width can be automatically extrapolated from
    toleranceINT3216–1024How many pixels at most the target width and height should be from each other. Greater values result in greater differences

    Outputs (3)

    NameTypeDescription
    Adj. WidthINTAdjusted width of the image after calculation
    Adj. HeightINTAdjust height of the image after calculation
    ResultSTRINGString expression that displays the performed calculation