From 090e4e837bd4e6f6558d0ba6ffbfbb54a63cf840 Mon Sep 17 00:00:00 2001 From: exdysa <91800957+exdysa@users.noreply.github.com> Date: Fri, 24 May 2024 18:09:03 -0400 Subject: [PATCH] Add files via upload --- selector.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 selector.py diff --git a/selector.py b/selector.py new file mode 100644 index 0000000..a9b569b --- /dev/null +++ b/selector.py @@ -0,0 +1,47 @@ +# + +class selector: + RATIO = [ + ("1:1 x512", 512, 512), + ("2:3 x768", 768, 512), + ("3:4 x682", 682, 512), + ("9:16 x910", 910, 512), + ("1:1.85 x952", 952, 512), + ("1:2 x1024", 1024, 512), + ("1:1 x768 2.0", 768, 768), + ("1:1 1024 XL", 1024, 1024), + ("3:2 832x1216 XL", 1216, 832), + ("3:4 896x1152 XL", 1152, 896), + ("9:16 768x1344 XL", 1344,768 ), + ("9:21 640x1536 XL", 1536, 640) + ] + + @classmethod + def INPUT_TYPES(cls): + aspect_ratio_titles = [title for title, _, _ in cls.RATIO] + ROTATION = ["landscape" , "portrait"] + + return { + "required": { + "aspectRatio": (aspect_ratio_titles,), + "rotation": (ROTATION,), + } + } + RETURN_TYPES = ("INT", "INT") + RETURN_NAMES = ("width", "height") + FUNCTION = "aspector" + CATEGORY = "image" + + def aspector(self, aspectRatio, rotation): + for title, width, height in self.RATIO: + if title == aspectRatio: + if rotation == "portrait": + width, height = height, width # Swap for portrait orientation + return (width, height) + return (None, None) # In case the aspect ratio is not found + + +NODE_CLASS_MAPPINGS = { "Selector": selector, } +NODE_DISPLAY_NAME_MAPPINGS = { "Selector": "Selector" } + +