From 87fe8c0de0bd005b1f6c6b3cec0ba67d2e8cdaeb Mon Sep 17 00:00:00 2001 From: jtrue Date: Thu, 7 Dec 2023 22:03:27 -0500 Subject: [PATCH] Add files via upload --- __init__.py | 26 ++++++++++++++ jru_concatstring.py | 35 +++++++++++++++++++ jru_concatstringwithdelimiter.py | 40 ++++++++++++++++++++++ jru_float2int.py | 38 +++++++++++++++++++++ jru_float2string.py | 38 +++++++++++++++++++++ jru_imagesizer.py | 58 ++++++++++++++++++++++++++++++++ jru_int2floatmultiply.py | 38 +++++++++++++++++++++ jru_int2string.py | 37 ++++++++++++++++++++ jru_string2int.py | 37 ++++++++++++++++++++ 9 files changed, 347 insertions(+) create mode 100644 __init__.py create mode 100644 jru_concatstring.py create mode 100644 jru_concatstringwithdelimiter.py create mode 100644 jru_float2int.py create mode 100644 jru_float2string.py create mode 100644 jru_imagesizer.py create mode 100644 jru_int2floatmultiply.py create mode 100644 jru_int2string.py create mode 100644 jru_string2int.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..ccbeac8 --- /dev/null +++ b/__init__.py @@ -0,0 +1,26 @@ +import importlib +import os + +node_list = [ #Add list of .py files containing nodes here + "jru_int2string", + "jru_concatstringwithdelimiter", + "jru_int2floatmultiply", + "jru_imagesizer", + "jru_float2string", + "jru_concatstring", + "jru_float2int", + "jru_string2int", + "jru_int2string" + +] + +NODE_CLASS_MAPPINGS = {} +NODE_DISPLAY_NAME_MAPPINGS = {} + +for module_name in node_list: + imported_module = importlib.import_module(".{}".format(module_name), __name__) + + NODE_CLASS_MAPPINGS = {**NODE_CLASS_MAPPINGS, **imported_module.NODE_CLASS_MAPPINGS} + NODE_DISPLAY_NAME_MAPPINGS = {**NODE_DISPLAY_NAME_MAPPINGS, **imported_module.NODE_DISPLAY_NAME_MAPPINGS} + +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] diff --git a/jru_concatstring.py b/jru_concatstring.py new file mode 100644 index 0000000..b1133be --- /dev/null +++ b/jru_concatstring.py @@ -0,0 +1,35 @@ +class ConcatString_jru: + + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string_a": ("STRING", {"forceInput":True,"default":"","multiline": True}), + "string_b": ("STRING", {"forceInput":True,"default":"","multiline": True}), + } + } + RETURN_TYPES = ("STRING", ) + FUNCTION = "concat" + + CATEGORY = "JaRue" + + def concat(self, string_a, string_b): + c = string_a + string_b + return (c,) + + + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "ConcatString_jru": ConcatString_jru +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "ConcatString_jru": "Concat String" +} \ No newline at end of file diff --git a/jru_concatstringwithdelimiter.py b/jru_concatstringwithdelimiter.py new file mode 100644 index 0000000..87f92fc --- /dev/null +++ b/jru_concatstringwithdelimiter.py @@ -0,0 +1,40 @@ +class ConcatStringWithDelimiter_jru: + + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string_a": ("STRING", {"forceInput":True,"default":"","multiline": False}), + "string_b": ("STRING", {"forceInput":True,"default":"","multiline": False}), + "string_c": ("STRING", {"forceInput":True,"default":"_","multiline": False}), + } + } + + + + + RETURN_TYPES = ("STRING", ) + FUNCTION = "concat" + + CATEGORY = "JaRue" + + def concat(self, string_a, string_b, string_c): + c = string_a + string_c + string_b + return (c,) + + + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "ConcatStringWithDelimiter_jru": ConcatStringWithDelimiter_jru +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "ConcatStringWithDelimiter_jru": "Concat Strings w/ Delimiter" +} \ No newline at end of file diff --git a/jru_float2int.py b/jru_float2int.py new file mode 100644 index 0000000..2ed682b --- /dev/null +++ b/jru_float2int.py @@ -0,0 +1,38 @@ +class Float2Int_jru: + + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "float_a": ("FLOAT", {"forceInput":True,"default":1,"min": 0}), + } + } + + + + + RETURN_TYPES = ("INT", ) + FUNCTION = "fFloat2Int" + + CATEGORY = "JaRue" + + def fFloat2Int(self, float_a): + c = int(float_a) + return (c,) + + + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "Float2Int_jru": Float2Int_jru +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "Float2Int_jru": "Convert Float to Integer" +} \ No newline at end of file diff --git a/jru_float2string.py b/jru_float2string.py new file mode 100644 index 0000000..7542539 --- /dev/null +++ b/jru_float2string.py @@ -0,0 +1,38 @@ +class Float2String_jru: + + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "float_a": ("FLOAT", {"forceInput":True,"default":1,"min": 0}), + } + } + + + + + RETURN_TYPES = ("STRING", ) + FUNCTION = "fFloat2String" + + CATEGORY = "JaRue" + + def fFloat2String(self, float_a): + c = str(float_a) + return (c,) + + + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "Float2String_jru": Float2String_jru +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "Float2String_jru": "Convert Float to String" +} \ No newline at end of file diff --git a/jru_imagesizer.py b/jru_imagesizer.py new file mode 100644 index 0000000..4d0ecfb --- /dev/null +++ b/jru_imagesizer.py @@ -0,0 +1,58 @@ +import math + +class ImageSizer_jru: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model_type": (["SD","SDXL"],), + "aspect_ratio_width": ("INT",{ + "default": 1, + "step":1, + "display": "number" + }), + "aspect_ratio_height": ("INT",{ + "default": 1, + "step":1, + "display": "number" + }) + } + } + + RETURN_TYPES = ("INT","INT") + RETURN_NAMES = ("Width", "Height") + + FUNCTION = "run" + + CATEGORY = "JaRue" + + def run(self, model_type, aspect_ratio_width, aspect_ratio_height): + # Define the total pixel counts for SD and SDXL + total_pixels = { + 'SD': 512 * 512, + 'SDXL': 1024 * 1024 + } + + # Calculate the number of total pixels based on model type + pixels = total_pixels.get(model_type, 0) + + # Calculate the aspect ratio decimal + aspect_ratio_decimal = aspect_ratio_width / aspect_ratio_height + + # Calculate width and height + width = math.sqrt(pixels * aspect_ratio_decimal) + height = pixels / width + + # Return the width and height as a tuple of integers + return (int(round(width)), int(round(height))) + +NODE_CLASS_MAPPINGS = { + "ImageSizer_jru": ImageSizer_jru +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "ImageSizer_jru": "Image Sizer" +} \ No newline at end of file diff --git a/jru_int2floatmultiply.py b/jru_int2floatmultiply.py new file mode 100644 index 0000000..bd9ad6c --- /dev/null +++ b/jru_int2floatmultiply.py @@ -0,0 +1,38 @@ +class Int2FloatMultiply_jru: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "int_a": ("INT", {"forceInput":True,"default":0,"min": 0}), + "float_b": ("FLOAT", {"forceInput":True,"default":1.0}), + } + } + + + + + RETURN_TYPES = ("FLOAT", ) + FUNCTION = "int2floatmlt" + + CATEGORY = "JaRue" + + def int2floatmlt(self, int_a, float_b): + c = int_a * float_b + return (c,) + + + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "Int2FloatMultiply_jru": Int2FloatMultiply_jru +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "Int2FloatMultiply_jru": "Convert Integer to Float w/ multiply" +} \ No newline at end of file diff --git a/jru_int2string.py b/jru_int2string.py new file mode 100644 index 0000000..6f51e8b --- /dev/null +++ b/jru_int2string.py @@ -0,0 +1,37 @@ +class Int2String_jru: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "int_a": ("INT", {"forceInput":True,"default":0,"min": 0}), + } + } + + + + + RETURN_TYPES = ("STRING", ) + FUNCTION = "concat" + + CATEGORY = "JaRue" + + def concat(self, int_a): + c = str(int_a) + return (c,) + + + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "Int2String_jru": Int2String_jru +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "Int2String_jru": "Convert Integer to String" +} \ No newline at end of file diff --git a/jru_string2int.py b/jru_string2int.py new file mode 100644 index 0000000..407010b --- /dev/null +++ b/jru_string2int.py @@ -0,0 +1,37 @@ +class String2Int_jru: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string_a": ("STRING", {"forceInput":True,"default":"","multiline": False}), + } + } + + + + + RETURN_TYPES = ("INT", ) + FUNCTION = "concat" + + CATEGORY = "JaRue" + + def concat(self, string_a): + c = int(string_a) + return (c,) + + + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "String2Int_jru": String2Int_jru +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "String2Int_jru": "Convert String to Integer" +} \ No newline at end of file