Upload SD_AspectRatio.py
Browse files- SD_AspectRatio.py +99 -0
SD_AspectRatio.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# quick node to set SDXL-friendly aspect ratios in 1024^2
|
2 |
+
# by throttlekitty
|
3 |
+
|
4 |
+
class SDXLAspectRatio:
|
5 |
+
def __init__(self):
|
6 |
+
pass
|
7 |
+
|
8 |
+
@classmethod
|
9 |
+
def INPUT_TYPES(s):
|
10 |
+
return {
|
11 |
+
"required": {
|
12 |
+
"width": ("INT", {"default": 64, "min": 64, "max": 2048,}),
|
13 |
+
"height": ("INT", {"default": 64, "min": 64, "max": 2048}),
|
14 |
+
"aspectRatio": ([
|
15 |
+
"custom",
|
16 |
+
"1:1 - 512x512 square",
|
17 |
+
"1:1 - 768x768 square",
|
18 |
+
"1:1 - 1024x1024 square",
|
19 |
+
"2:3 - 512x768 photo portrait",
|
20 |
+
"3:2 - 768x512 photo landscape",
|
21 |
+
"4:5 - 512x912 social media",
|
22 |
+
"4:5 - 768x960 social media",
|
23 |
+
"2:3 - 768x1152 photo portrait",
|
24 |
+
"3:2 - 1152x768 photo landscape",
|
25 |
+
"2:3 - 832x1216 portrait",
|
26 |
+
"3:4 - 896x1152 portrait",
|
27 |
+
"5:8 - 768x1216 portrait",
|
28 |
+
"9:16 - 768x1344 portrait",
|
29 |
+
"9:19 - 704x1472 portrait",
|
30 |
+
"9:21 - 640x1536 portrait",
|
31 |
+
"3:2 - 1216x832 landscape",
|
32 |
+
"4:3 - 1152x896 landscape",
|
33 |
+
"8:5 - 1216x768 landscape",
|
34 |
+
"16:9 - 1365x768 standard monitor",
|
35 |
+
"16:9 - 1344x768 landscape",
|
36 |
+
"19:9 - 1472x704 landscape",
|
37 |
+
"21:9 - 1536x640 landscape"],)
|
38 |
+
}
|
39 |
+
}
|
40 |
+
RETURN_TYPES = ("INT", "INT")
|
41 |
+
RETURN_NAMES = ("Width", "Height")
|
42 |
+
FUNCTION = "SDXL_AspectRatio"
|
43 |
+
CATEGORY = "image"
|
44 |
+
|
45 |
+
def SDXL_AspectRatio(self, width, height, aspectRatio):
|
46 |
+
if aspectRatio == "1:1 - 512x512 square":
|
47 |
+
width, height = 512, 512
|
48 |
+
elif aspectRatio == "custom":
|
49 |
+
width = width
|
50 |
+
height = height
|
51 |
+
elif aspectRatio == "1:1 - 768x768 square":
|
52 |
+
width, height = 768, 768
|
53 |
+
elif aspectRatio == "1:1 - 1024x1024 square":
|
54 |
+
width, height = 1024, 1024
|
55 |
+
elif aspectRatio == "2:3 - 832x1216 portrait":
|
56 |
+
width, height = 832, 1216
|
57 |
+
elif aspectRatio == "3:4 - 896x1152 portrait":
|
58 |
+
width, height = 896, 1152
|
59 |
+
elif aspectRatio == "5:8 - 768x1216 portrait":
|
60 |
+
width, height = 768, 1216
|
61 |
+
elif aspectRatio == "9:16 - 768x1344 portrait":
|
62 |
+
width, height = 768, 1344
|
63 |
+
elif aspectRatio == "9:19 - 704x1472 portrait":
|
64 |
+
width, height = 704, 1472
|
65 |
+
elif aspectRatio == "9:21 - 640x1536 portrait":
|
66 |
+
width, height = 640, 1536
|
67 |
+
elif aspectRatio == "3:2 - 1216x832 landscape":
|
68 |
+
width, height = 1216, 832
|
69 |
+
elif aspectRatio == "4:3 - 1152x896 landscape":
|
70 |
+
width, height = 1152, 896
|
71 |
+
elif aspectRatio == "8:5 - 1216x768 landscape":
|
72 |
+
width, height = 1216, 768
|
73 |
+
elif aspectRatio == "16:9 - 1344x768 landscape":
|
74 |
+
width, height = 1344, 768
|
75 |
+
elif aspectRatio == "16:9 - 1365x768 standard monitor":
|
76 |
+
width, height = 1365, 768
|
77 |
+
elif aspectRatio == "19:9 - 1472x704 landscape":
|
78 |
+
width, height = 1472, 704
|
79 |
+
elif aspectRatio == "21:9 - 1536x640 landscape":
|
80 |
+
width, height = 1536, 640
|
81 |
+
elif aspectRatio == "2:3 - 512x768 photo portrait":
|
82 |
+
width, height = 512, 768
|
83 |
+
elif aspectRatio == "3:2 - 768x512 photo landscape":
|
84 |
+
width, height = 768, 512
|
85 |
+
elif aspectRatio == "4:5 - 768x960 social media":
|
86 |
+
width, height = 768, 960
|
87 |
+
elif aspectRatio == "2:3 - 768x1152 photo portrait":
|
88 |
+
width, height = 768, 1152
|
89 |
+
elif aspectRatio == "3:2 - 1152x768 photo landscape":
|
90 |
+
width, height = 1152, 768
|
91 |
+
return(width, height)
|
92 |
+
|
93 |
+
|
94 |
+
NODE_CLASS_MAPPINGS = {
|
95 |
+
"SDXLAspectRatio": SDXLAspectRatio
|
96 |
+
}
|
97 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
98 |
+
"SDXLAspectRatio": "SD Aspect Ratio"
|
99 |
+
}
|