├── .github └── workflows │ └── publish.yml ├── README.md ├── SDXLAspectRatio.py └── pyproject.toml /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish to Comfy registry 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - "pyproject.toml" 9 | 10 | permissions: 11 | issues: write 12 | 13 | jobs: 14 | publish-node: 15 | name: Publish Custom Node to registry 16 | runs-on: ubuntu-latest 17 | if: ${{ github.repository_owner == 'throttlekitty' }} 18 | steps: 19 | - name: Check out code 20 | uses: actions/checkout@v4 21 | - name: Publish Custom Node 22 | uses: Comfy-Org/publish-node-action@v1 23 | with: 24 | ## Add your own personal access token to your Github Repository secrets and reference it here. 25 | personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SDXLCustomAspectRatio 2 | A quick and easy ComfyUI custom node for setting SDXL-friendly aspect ratios 3 | 4 | git clone or download this python file directly to comfyui/custom_nodes/ 5 | -------------------------------------------------------------------------------- /SDXLAspectRatio.py: -------------------------------------------------------------------------------- 1 | # quick node to set SDXL-friendly aspect ratios in 1024^2 2 | # by throttlekitty 3 | import re 4 | 5 | 6 | class SDXLAspectRatio: 7 | def __init__(self): 8 | pass 9 | 10 | @classmethod 11 | def INPUT_TYPES(s): 12 | return { 13 | "required": { 14 | "aspectRatio": ([ 15 | "1:1 - 512x512 square", 16 | "1:1 - 640x640 square", 17 | "1:1 - 768x768 square", 18 | "1:1 - 1024x1024 square", 19 | "1:1 - 1280x1280 square", 20 | "1:1 - 1536x1536 square", 21 | "1:1 - 2048x2048 square", 22 | "2:3 - 512x736 portrait", 23 | "2:3 - 512x768 portrait", 24 | "2:3 - 832x1216 portrait", 25 | "2:3 - 1344x2048 portrait", 26 | "2:3 - 1664x2432 portrait", 27 | "3:4 - 896x1152 portrait", 28 | "5:8 - 768x1216 portrait", 29 | "9:16 - 768x1344 portrait", 30 | "9:19 - 704x1472 portrait", 31 | "9:21 - 640x1536 portrait", 32 | "3:2 - 1536x640 landscape", 33 | "3:2 - 736x512 landscape", 34 | "3:2 - 768x512 landscape", 35 | "3:2 - 1216x832 landscape", 36 | "3:2 - 2048x1344 landscape", 37 | "3:2 - 2432x1664 landscape", 38 | "4:3 - 1152x896 landscape", 39 | "8:5 - 1216x768 landscape", 40 | "16:9 - 1344x768 landscape", 41 | "19:9 - 1472x704 landscape", 42 | "21:9 - 1536x640 landscape"],) 43 | } 44 | } 45 | RETURN_TYPES = ("INT", "INT") 46 | RETURN_NAMES = ("Width", "Height") 47 | FUNCTION = "SDXL_AspectRatio" 48 | CATEGORY = "image" 49 | 50 | def SDXL_AspectRatio(self, aspectRatio): 51 | # Matches aspectRatio text on any number of digits, an x and any number of digits 52 | pattern = r"(\d+)\s*[xX]\s*(\d+)" 53 | match = re.search(pattern, aspectRatio) 54 | 55 | if match: 56 | width = int(match.group(1)) 57 | height = int(match.group(2)) 58 | else: 59 | width, height = 1024, 1024 60 | 61 | return width, height 62 | 63 | 64 | NODE_CLASS_MAPPINGS = { 65 | "SDXLAspectRatio": SDXLAspectRatio 66 | } 67 | NODE_DISPLAY_NAME_MAPPINGS = { 68 | "SDXLAspectRatio": "SDXL Aspect Ratio" 69 | } 70 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "sdxlcustomaspectratio" 3 | description = "A quick and easy ComfyUI custom node for setting SDXL-friendly aspect ratios." 4 | version = "1.0.1" 5 | license = "LICENSE" 6 | 7 | [project.urls] 8 | Repository = "https://github.com/throttlekitty/SDXLCustomAspectRatio" 9 | # Used by Comfy Registry https://comfyregistry.org 10 | 11 | [tool.comfy] 12 | PublisherId = "throttlekitty" 13 | DisplayName = "SDXLCustomAspectRatio" 14 | Icon = "" 15 | --------------------------------------------------------------------------------