Skip to content

Commit 80d4944

Browse files
refactor: use AspectRatio enum members as ASPECT_RATIOS dict keys (Comfy-Org#12689)
Amp-Thread-ID: https://ampcode.com/threads/T-019ca1cb-0150-7549-8b1b-6713060d3408 Co-authored-by: Jedrzej Kosinski <kosinkadink1@gmail.com>
1 parent 9d0e114 commit 80d4944

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

comfy_extras/nodes_resolution.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ class AspectRatio(str, Enum):
1616
WIDESCREEN_V = "9:16 (Portrait Widescreen)"
1717

1818

19-
ASPECT_RATIOS: dict[str, tuple[int, int]] = {
20-
"1:1 (Square)": (1, 1),
21-
"3:2 (Photo)": (3, 2),
22-
"4:3 (Standard)": (4, 3),
23-
"16:9 (Widescreen)": (16, 9),
24-
"21:9 (Ultrawide)": (21, 9),
25-
"2:3 (Portrait Photo)": (2, 3),
26-
"3:4 (Portrait Standard)": (3, 4),
27-
"9:16 (Portrait Widescreen)": (9, 16),
19+
ASPECT_RATIOS: dict[AspectRatio, tuple[int, int]] = {
20+
AspectRatio.SQUARE: (1, 1),
21+
AspectRatio.PHOTO_H: (3, 2),
22+
AspectRatio.STANDARD_H: (4, 3),
23+
AspectRatio.WIDESCREEN_H: (16, 9),
24+
AspectRatio.ULTRAWIDE_H: (21, 9),
25+
AspectRatio.PHOTO_V: (2, 3),
26+
AspectRatio.STANDARD_V: (3, 4),
27+
AspectRatio.WIDESCREEN_V: (9, 16),
2828
}
2929

3030

@@ -55,8 +55,12 @@ def define_schema(cls):
5555
),
5656
],
5757
outputs=[
58-
io.Int.Output("width", tooltip="Calculated width in pixels (multiple of 8)."),
59-
io.Int.Output("height", tooltip="Calculated height in pixels (multiple of 8)."),
58+
io.Int.Output(
59+
"width", tooltip="Calculated width in pixels (multiple of 8)."
60+
),
61+
io.Int.Output(
62+
"height", tooltip="Calculated height in pixels (multiple of 8)."
63+
),
6064
],
6165
)
6266

0 commit comments

Comments
 (0)