ComfyUI  >  Nodes  >  ComfyMath >  NearestSDXLResolution

ComfyUI Node: NearestSDXLResolution

Class Name


evanspearman (Account age: 4247 days)
Latest Updated
Github Stars

How to Install ComfyMath

Install this extension via the ComfyUI Manager by searching for  ComfyMath
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyMath in the search bar
After installation, click the  Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

NearestSDXLResolution Description

Find closest supported SDXL resolution for images based on aspect ratio, ensuring compatibility and optimal results in AI art projects.


The CM_NearestSDXLResolution node is designed to help you find the closest supported SDXL resolution for a given image. This node is particularly useful when you need to ensure that your image conforms to one of the predefined resolutions supported by SDXL, which can be crucial for maintaining compatibility and achieving optimal results in your AI art projects. By analyzing the aspect ratio of your input image, this node identifies the nearest resolution from a list of supported resolutions, making it easier for you to work with images that meet specific requirements without manually adjusting dimensions.

NearestSDXLResolution Input Parameters:


The image parameter expects an image input. This image is analyzed to determine its width and height, which are then used to calculate its aspect ratio. The aspect ratio is compared against a list of supported SDXL resolutions to find the closest match. This parameter is essential as it directly influences the resolution selection process.

NearestSDXLResolution Output Parameters:


The width output parameter provides the width of the nearest supported SDXL resolution. This value is determined based on the aspect ratio of the input image and the closest match from the predefined list of resolutions. It ensures that the image width is compatible with SDXL standards.


The height output parameter provides the height of the nearest supported SDXL resolution. Similar to the width parameter, this value is derived from the aspect ratio of the input image and the closest match from the supported resolutions list. It ensures that the image height is compatible with SDXL standards.

NearestSDXLResolution Usage Tips:

  • Ensure that the input image has a clear and defined aspect ratio to get the most accurate nearest resolution match.
  • Use this node when preparing images for SDXL-based models to maintain compatibility and achieve optimal results without manual resizing.

NearestSDXLResolution Common Errors and Solutions:

"Input image resolution not found"

  • Explanation: This error occurs when the input image's aspect ratio does not closely match any of the supported SDXL resolutions.
  • Solution: Verify the aspect ratio of your input image and ensure it is within a reasonable range of the supported resolutions. If necessary, manually adjust the image dimensions to better match the supported aspect ratios.

"Invalid image input"

  • Explanation: This error occurs when the provided input is not a valid image.
  • Solution: Ensure that the input parameter is a valid image file. Check the file format and integrity of the image before inputting it into the node.

NearestSDXLResolution Related Nodes

Go back to the extension to check out more related nodes.

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.