sdset / SD_AspectRatio.py
hvai's picture
Upload SD_AspectRatio.py
0ce5540
raw
history blame
4.05 kB
# quick node to set SDXL-friendly aspect ratios in 1024^2
# by throttlekitty
class SDXLAspectRatio:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"width": ("INT", {"default": 64, "min": 64, "max": 2048,}),
"height": ("INT", {"default": 64, "min": 64, "max": 2048}),
"aspectRatio": ([
"custom",
"1:1 - 512x512 square",
"1:1 - 768x768 square",
"1:1 - 1024x1024 square",
"2:3 - 512x768 photo portrait",
"3:2 - 768x512 photo landscape",
"4:5 - 512x912 social media",
"4:5 - 768x960 social media",
"2:3 - 768x1152 photo portrait",
"3:2 - 1152x768 photo landscape",
"2:3 - 832x1216 portrait",
"3:4 - 896x1152 portrait",
"5:8 - 768x1216 portrait",
"9:16 - 768x1344 portrait",
"9:19 - 704x1472 portrait",
"9:21 - 640x1536 portrait",
"3:2 - 1216x832 landscape",
"4:3 - 1152x896 landscape",
"8:5 - 1216x768 landscape",
"16:9 - 1365x768 standard monitor",
"16:9 - 1344x768 landscape",
"19:9 - 1472x704 landscape",
"21:9 - 1536x640 landscape"],)
}
}
RETURN_TYPES = ("INT", "INT")
RETURN_NAMES = ("Width", "Height")
FUNCTION = "SDXL_AspectRatio"
CATEGORY = "image"
def SDXL_AspectRatio(self, width, height, aspectRatio):
if aspectRatio == "1:1 - 512x512 square":
width, height = 512, 512
elif aspectRatio == "custom":
width = width
height = height
elif aspectRatio == "1:1 - 768x768 square":
width, height = 768, 768
elif aspectRatio == "1:1 - 1024x1024 square":
width, height = 1024, 1024
elif aspectRatio == "2:3 - 832x1216 portrait":
width, height = 832, 1216
elif aspectRatio == "3:4 - 896x1152 portrait":
width, height = 896, 1152
elif aspectRatio == "5:8 - 768x1216 portrait":
width, height = 768, 1216
elif aspectRatio == "9:16 - 768x1344 portrait":
width, height = 768, 1344
elif aspectRatio == "9:19 - 704x1472 portrait":
width, height = 704, 1472
elif aspectRatio == "9:21 - 640x1536 portrait":
width, height = 640, 1536
elif aspectRatio == "3:2 - 1216x832 landscape":
width, height = 1216, 832
elif aspectRatio == "4:3 - 1152x896 landscape":
width, height = 1152, 896
elif aspectRatio == "8:5 - 1216x768 landscape":
width, height = 1216, 768
elif aspectRatio == "16:9 - 1344x768 landscape":
width, height = 1344, 768
elif aspectRatio == "16:9 - 1365x768 standard monitor":
width, height = 1365, 768
elif aspectRatio == "19:9 - 1472x704 landscape":
width, height = 1472, 704
elif aspectRatio == "21:9 - 1536x640 landscape":
width, height = 1536, 640
elif aspectRatio == "2:3 - 512x768 photo portrait":
width, height = 512, 768
elif aspectRatio == "3:2 - 768x512 photo landscape":
width, height = 768, 512
elif aspectRatio == "4:5 - 768x960 social media":
width, height = 768, 960
elif aspectRatio == "2:3 - 768x1152 photo portrait":
width, height = 768, 1152
elif aspectRatio == "3:2 - 1152x768 photo landscape":
width, height = 1152, 768
return(width, height)
NODE_CLASS_MAPPINGS = {
"SDXLAspectRatio": SDXLAspectRatio
}
NODE_DISPLAY_NAME_MAPPINGS = {
"SDXLAspectRatio": "SD Aspect Ratio"
}