From d6ff722ba85d931e47baf0f619b002d0ec58ada8 Mon Sep 17 00:00:00 2001 From: Suzie1 <7.lyssa@gmail.com> Date: Thu, 18 Jan 2024 15:41:19 +0000 Subject: [PATCH] verson 1.74 --- Patch_Notes.md | 9 + README.md | 7 +- __init__.py | 4 +- config.py | 42 ++- node_mappings.py | 16 +- nodes/nodes_aspect_ratio.py | 82 +++++- nodes/nodes_graphics_layout.py | 34 ++- nodes/nodes_graphics_template.py | 32 +-- nodes/nodes_list.py | 6 +- nodes/nodes_utils_other.py | 191 +++++++------- ...> CR_Overlay_Transparent_Image_demo1.json} | 0 .../Template/CR_Seamless_Checker_demo1.json | 105 ++++++++ .../CR_Simple_Image_Compare_demo1.json | 240 ++++++++++++++++++ 13 files changed, 640 insertions(+), 128 deletions(-) rename workflows/Graphics/Layout/{CR_Overlay_Transparent_Image_demo2.json => CR_Overlay_Transparent_Image_demo1.json} (100%) create mode 100644 workflows/Graphics/Template/CR_Seamless_Checker_demo1.json create mode 100644 workflows/Graphics/Template/CR_Simple_Image_Compare_demo1.json diff --git a/Patch_Notes.md b/Patch_Notes.md index b7148f5..7a7def1 100644 --- a/Patch_Notes.md +++ b/Patch_Notes.md @@ -1,5 +1,14 @@ # 🧩 Comfyroll Studio - Patch Notes +## v1.74 Jan 18, 2024 +- changed CR Simple Image Compare to automatically resize the second image if the size is different +- added CR Aspect Ratio For Print +- added CR Seamless Checker +- added CR Select ISO Size + +## v1.73.1 Jan 17, 2024 +- fix for issue 104 + ## v1.73 Jan 17, 2024 - added CR String to Boolean - updated CR Aspect Ratio Social Media, added more options diff --git a/README.md b/README.md index 91ca0d1..18a8cb8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Co-authored by Suzie1 and RockOfFire -Current version: 1.73 +Current version: 1.74 # Wiki @@ -40,7 +40,8 @@ __🔳 Aspect Ratio__ * CR SDXL Aspect Ratio * CR SD1.5 Aspect Ratio * CR Aspect Ratio Banners (new 18/12/2023) -* CR Aspect Ratio Social Media (new 15/1/2024) +* CR Aspect Ratio Social Media (new 15/1/2024) +* CR Aspect Ratio For Print (new 18/1/2024) __📜 List Nodes__ * CR Text List (new 19/12/2023) @@ -156,6 +157,7 @@ __👽 Graphics - Template__ * CR Simple Banner (new 18/12/2023) * CR Simple Image Compare (new 18/12/2023) * CR Thumbnail Preview (new 26/12/2023) +* CR Seamless Checker (new 18/1/2023) __🌁 Graphics - Layout__ * CR Image Panel @@ -166,6 +168,7 @@ __🌁 Graphics - Layout__ * CR Color Panel * CR Simple Text Panel * CR Overlay Transparent Image +* CR Select ISO Size (new 18/1/2023) ## 🎥 Animation diff --git a/__init__.py b/__init__.py index c67323d..fdcfdc4 100644 --- a/__init__.py +++ b/__init__.py @@ -15,13 +15,13 @@ @author: Suzie1 @title: Comfyroll Studio @nickname: Comfyroll Studio -@description: 170 custom nodes for artists, designers and animators. +@description: 175 custom nodes for artists, designers and animators. """ from .node_mappings import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS print("------------------------------------------") -print("\033[34mComfyroll Studio v1.73 : \033[92m 170 Nodes Loaded\033[0m") +print("\033[34mComfyroll Studio v1.74 : \033[92m 175 Nodes Loaded\033[0m") print("------------------------------------------") print("** For changes, please see patch notes at https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/blob/main/Patch_Notes.md") print("** For help, please see the wiki at https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki") diff --git a/config.py b/config.py index 7cc0655..bd6eeba 100644 --- a/config.py +++ b/config.py @@ -34,4 +34,44 @@ "cyan", "magenta", "orange", "purple", "pink", "brown", "gray", "lightgray", "darkgray", "olive", "lime", "teal", "navy", "maroon", "fuchsia", "aqua", "silver", "gold", "turquoise", "lavender", - "violet", "coral", "indigo"] \ No newline at end of file + "violet", "coral", "indigo"] + +iso_sizes = { + "A0 - 9933x14043": (9933, 14043), + "A1 - 7016x9933": (7016, 9933), + "A2 - 4960x7016": (4960, 7016), + "A3 - 3508x4960": (3508, 4960), + "A4 - 2480x3508": (2480, 3508), + "A5 - 1748x2480": (1748, 2480), + "A6 - 1240x1748": (1240, 1748), + "A7 - 874x1240": (874, 1240), + "A8 - 614x874": (614, 874), + "A9 - 437x614": (437, 614), + "A10 - 307x437": (307, 437), + "A11 - 213x307": (213, 307), + "A12 - 154x213": (154, 213), + "A13 - 106x154": (106, 154), + "B0 - 11811x16701": (11811, 16701), + "B1 - 8350x11811": (8350, 11811), + "B2 - 5906x8350": (5906, 8350), + "B3 - 4169x5906": (4169, 5906), + "B4 - 2953x4169": (2953, 4169), + "B5 - 2079x2953": (2079, 2953), + "B6 - 1476x2079": (1476, 2079), + "B7 - 1039x1476": (1039, 1476), + "B8 - 732x1039": (732, 1039), + "B9 - 520x732": (520, 732), + "B10 - 366x520": (366, 520), + "C0 - 10831x15319": (10831, 15319), + "C1 - 7654x10831": (7654, 10831), + "C2 - 5409x7654": (5409, 7654), + "C3 - 3827x5409": (3827, 5409), + "C4 - 2705x3827": (2705, 3827), + "C5 - 1913x2705": (1913, 2705), + "C6 - 1346x1913": (1346, 1913), + "C7 - 957x1346": (957, 1346), + "C8 - 673x957": (673, 957), + "C9 - 472x673": (472, 673), + "C10 - 331x472": (331, 472), +} + \ No newline at end of file diff --git a/node_mappings.py b/node_mappings.py index 77c61bf..5e2a49b 100644 --- a/node_mappings.py +++ b/node_mappings.py @@ -79,7 +79,8 @@ "CR SDXL Aspect Ratio": CR_SDXLAspectRatio, "CR Aspect Ratio": CR_AspectRatio, "CR Aspect Ratio Banners": CR_AspectRatioBanners, - "CR Aspect Ratio Social Media": CR_AspectRatioSocialMedia, + "CR Aspect Ratio Social Media": CR_AspectRatioSocialMedia, + "CR_Aspect Ratio For Print": CR_AspectRatioForPrint, ### Legacy Nodes "CR Image Size": CR_ImageSize, "CR Aspect Ratio SDXL": CR_AspectRatio_SDXL, @@ -168,7 +169,8 @@ "CR Simple Banner": CR_SimpleBanner, "CR Comic Panel Templates": CR_ComicPanelTemplates, "CR Simple Image Compare": CR_SimpleImageCompare, - "CR Thumbnail Preview": CR_ThumbnailPreview, + "CR Thumbnail Preview": CR_ThumbnailPreview, + "CR Seamless Checker": CR_SeamlessChecker, ### Utils Logic "CR Image Input Switch": CR_ImageInputSwitch, "CR Image Input Switch (4 way)": CR_ImageInputSwitch4way, @@ -227,6 +229,7 @@ "CR Math Operation": CR_MathOperation, "CR Get Parameter From Prompt": CR_GetParameterFromPrompt, "CR Select Resize Method": CR_SelectResizeMethod, + "CR Select ISO Size": CR_SelectISOSize, ### Animation Nodes # Schedules "CR Simple Schedule": CR_SimpleSchedule, @@ -319,7 +322,8 @@ "CR SDXL Aspect Ratio": "🔳 CR SDXL Aspect Ratio", "CR Aspect Ratio": "🔳 CR Aspect Ratio", "CR Aspect Ratio Banners": "🔳 CR Aspect Ratio Banners", - "CR Aspect Ratio Social Media": "🔳 CR Aspect Ratio Social Media", + "CR Aspect Ratio Social Media": "🔳 CR Aspect Ratio Social Media", + "CR_Aspect Ratio For Print": "🔳 CR_Aspect Ratio For Print", ### Legacy Nodes "CR Image Size": "CR Image Size (Legacy)", "CR Aspect Ratio SDXL": "CR Aspect Ratio SDXL (Legacy)", @@ -405,7 +409,8 @@ "CR Simple Banner": "📱 CR Simple Banner", "CR Comic Panel Templates": "📱 CR Comic Panel Templates", "CR Simple Image Compare": "📱 CR Simple Image Compare", - "CR Thumbnail Preview": "📱 CR Thumbnail Preview", + "CR Thumbnail Preview": "📱 CR Thumbnail Preview", + "CR Seamless Checker": "📱 CR Seamless Checker", ### Utils Logic "CR Image Input Switch": "🔀 CR Image Input Switch", "CR Image Input Switch (4 way)": "🔀 CR Image Input Switch (4 way)", @@ -463,7 +468,8 @@ "CR Clamp Value": "⚙️ CR Clamp Value", "CR Math Operation": "⚙️ CR Math Operation", "CR Get Parameter From Prompt": "⚙️ CR Get Parameter From Prompt", - "CR Select Resize Method": "⚙️ CR Select Resize Method", + "CR Select Resize Method": "⚙️ CR Select Resize Method", + "CR Select ISO Size": "⚙️ CR Select ISO Size", ### Animation Nodes # Schedules "CR Simple Schedule": "📋 CR Simple Schedule", diff --git a/nodes/nodes_aspect_ratio.py b/nodes/nodes_aspect_ratio.py index 81be698..f276f31 100644 --- a/nodes/nodes_aspect_ratio.py +++ b/nodes/nodes_aspect_ratio.py @@ -6,6 +6,32 @@ import torch from ..categories import icons +PRINT_SIZES = { + "A4 - 2480x3508": (2480, 3508), + "A5 - 1748x2480": (1748, 2480), + "A6 - 1240x1748": (1240, 1748), + "A7 - 874x1240": (874, 1240), + "A8 - 614x874": (614, 874), + "A9 - 437x614": (437, 614), + "A10 - 307x437": (307, 437), + "B4 - 2953x4169": (2953, 4169), + "B5 - 2079x2953": (2079, 2953), + "B6 - 1476x2079": (1476, 2079), + "B7 - 1039x1476": (1039, 1476), + "B8 - 732x1039": (732, 1039), + "B9 - 520x732": (520, 732), + "B10 - 366x520": (366, 520), + "C4 - 2705x3827": (2705, 3827), + "C5 - 1913x2705": (1913, 2705), + "C6 - 1346x1913": (1346, 1913), + "C7 - 957x1346": (957, 1346), + "C8 - 673x957": (673, 957), + "C9 - 472x673": (472, 673), + "C10 - 331x472": (331, 472), + "Letter (8.5 x 11 inches) - 2550x3300": (2550, 3300), + "Legal (8.5 x 14 inches) - 2550x4200": (2550, 4200) +} + #---------------------------------------------------------------------------------------------------------------------# # Aspect Ratio Nodes #---------------------------------------------------------------------------------------------------------------------# @@ -319,8 +345,6 @@ def Aspect_Ratio(self, width, height, aspect_ratio, swap_dimensions, upscale_fac #---------------------------------------------------------------------------------------------------------------------# class CR_AspectRatioSocialMedia: - def __init__(self): - pass @classmethod def INPUT_TYPES(s): @@ -339,6 +363,7 @@ def INPUT_TYPES(s): "LinkedIn Page Cover - 1128x191", "LinkedIn Post - 1200x627", "Pinterest Pin Image - 1000x1500", + "CivitAI Cover - 1600x400", "OpenArt App - 1500x1000" ] @@ -360,7 +385,7 @@ def INPUT_TYPES(s): def Aspect_Ratio(self, width, height, aspect_ratio, swap_dimensions, upscale_factor, prescale_factor, batch_size): - # Banner sizes + # Social media sizes if aspect_ratio == "Instagram Portrait - 1080x1350": width, height = 1080, 1350 elif aspect_ratio == "Instagram Square - 1080x1080": @@ -388,7 +413,9 @@ def Aspect_Ratio(self, width, height, aspect_ratio, swap_dimensions, upscale_fac elif aspect_ratio == "Pinterest Pin Image - 1000x1500": width, height = 1000, 1500 elif aspect_ratio == "Pinterest Cover Image - 1920x1080": - width, height = 1920, 1080 + width, height = 1920, 1080 + elif aspect_ratio == "CivitAI Cover - 1600x400": + width, height = 1600, 400 elif aspect_ratio == "OpenArt App - 1500x1000": width, height = 1500, 1000 @@ -403,6 +430,50 @@ def Aspect_Ratio(self, width, height, aspect_ratio, swap_dimensions, upscale_fac show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Aspect-Ratio-Nodes#cr-aspect-ratio-scial-media" return(width, height, upscale_factor, prescale_factor, batch_size, {"samples":latent}, show_help, ) + +#---------------------------------------------------------------------------------------------------------------------# +class CR_AspectRatioForPrint: + + @classmethod + def INPUT_TYPES(cls): + + aspect_ratios = list(PRINT_SIZES.keys()) + + return { + "required": { + "width": ("INT", {"default": 1024, "min": 64, "max": 8192}), + "height": ("INT", {"default": 1024, "min": 64, "max": 8192}), + "aspect_ratio": (aspect_ratios,), + "swap_dimensions": (["Off", "On"],), + "upscale_factor": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 100.0, "step":0.1}), + "prescale_factor": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 100.0, "step":0.1}), + "batch_size": ("INT", {"default": 1, "min": 1, "max": 64}) + } + } + RETURN_TYPES = ("INT", "INT", "FLOAT", "FLOAT", "INT", "LATENT", "STRING", ) + RETURN_NAMES = ("width", "height", "upscale_factor", "prescale_factor", "batch_size", "empty_latent", "show_help", ) + FUNCTION = "Aspect_Ratio" + CATEGORY = icons.get("Comfyroll/Aspect Ratio") + + def Aspect_Ratio(self, width, height, aspect_ratio, swap_dimensions, upscale_factor, prescale_factor, batch_size): + + # Iso sizes + if aspect_ratio in PRINT_SIZES: + width, height = PRINT_SIZES[aspect_ratio] + + if swap_dimensions == "On": + width, height = height, width + + width = int(width*prescale_factor) + height = int(height*prescale_factor) + + print(f"Width: {width}, Height: {height}") + + latent = torch.zeros([batch_size, 4, height // 8, width // 8]) + + show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Aspect-Ratio-Nodes#cr-aspect-ratio-scial-media" + + return(width, height, upscale_factor, prescale_factor, batch_size, {"samples":latent}, show_help, ) #---------------------------------------------------------------------------------------------------------------------# # MAPPINGS @@ -415,7 +486,8 @@ def Aspect_Ratio(self, width, height, aspect_ratio, swap_dimensions, upscale_fac "CR SDXL Aspect Ratio": CR_SDXLAspectRatio, "CR Aspect Ratio": CR_AspectRatio, "CR Aspect Ratio Banners": CR_AspectRatioBanners, - "CR Aspect Ratio Social Media": CR_AspectRatioSocialMedia, + "CR Aspect Ratio Social Media": CR_AspectRatioSocialMedia, + "CR_Aspect Ratio For Print": CR_AspectRatioForPrint, } ''' diff --git a/nodes/nodes_graphics_layout.py b/nodes/nodes_graphics_layout.py index 52fc80b..99c2381 100644 --- a/nodes/nodes_graphics_layout.py +++ b/nodes/nodes_graphics_layout.py @@ -9,6 +9,7 @@ from PIL import Image, ImageDraw, ImageOps, ImageFont, ImageFilter from ..categories import icons from ..config import color_mapping, COLORS +from ..config import iso_sizes from .functions_graphics import * #---------------------------------------------------------------------------------------------------------------------# @@ -607,6 +608,36 @@ def make_border(self, image, return (images, show_help, ) +#---------------------------------------------------------------------------------------------------------------------# +class CR_SelectISOSize: + + @classmethod + def INPUT_TYPES(cls): + + sizes = list(iso_sizes.keys()) + + return { + "required": { + "iso_size": (sizes, ), + } + } + + RETURN_TYPES =("INT", "INT","STRING", ) + RETURN_NAMES =("width", "height","show_help", ) + FUNCTION = "get_size" + CATEGORY = icons.get("Comfyroll/Utils/Other") + + def get_size(self, iso_size): + + if iso_size in iso_sizes: + width, height = iso_sizes[iso_size] + else: + print("Size not found.") + + show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Other-Nodes#cr-select-iso-size" + + return (width, height, show_help, ) + #---------------------------------------------------------------------------------------------------------------------# # MAPPINGS #---------------------------------------------------------------------------------------------------------------------# @@ -621,7 +652,8 @@ def make_border(self, image, "CR Color Panel": CR_ColorPanel, "CR Simple Text Panel": CR_SimpleTextPanel, "CR Overlay Transparent Image": CR_OverlayTransparentImage, - "CR Simple Titles": CR_SimpleTitles, + #"CR Simple Titles": CR_SimpleTitles, + "CR Select ISO Size": CR_SelectISOSize, } ''' diff --git a/nodes/nodes_graphics_template.py b/nodes/nodes_graphics_template.py index 433a29c..05b6d98 100644 --- a/nodes/nodes_graphics_template.py +++ b/nodes/nodes_graphics_template.py @@ -421,6 +421,8 @@ def layout(self, text1, text2, footer_height, font_name, font_size, mode, border_thickness, image1=None, image2=None): + show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Layout-Nodes#cr-simple-image-compare" + # Get RGB values for the text and background colors if mode == "normal": font_color = "black" @@ -433,10 +435,12 @@ def layout(self, text1, text2, img1 = tensor2pil(image1) img2 = tensor2pil(image2) - + # Get image width and height - image_width = img1.width - image_height = img1.height + image_width, image_height = img1.width, img1.height + + if img2.width != img1.width or img2.height != img1.height: + img2 = apply_resize_image(img2, image_width, image_height, 8, "rescale", "false", 1, 256, "lanczos") # Set defaults margins = 50 @@ -494,8 +498,6 @@ def layout(self, text1, text2, if border_thickness > 0: result_img = ImageOps.expand(result_img, border_thickness, bg_color) - show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Layout-Nodes#cr-simple_image_compare" - return (pil2tensor(result_img), show_help, ) #--------------------------------------------------------------------------------------------------------------------- @@ -560,7 +562,7 @@ def INPUT_TYPES(s): return {"required": {"image": ("IMAGE",), "rescale_factor": ("FLOAT", {"default": 0.25, "min": 0.10, "max": 1.00, "step": 0.01}), - "max_columns": ("INT", {"default": 5, "min": 0, "max": 256}), + "grid_options": (["2x2", "3x3", "4x4", "5x5", "6x6"],), } } @@ -570,21 +572,21 @@ def INPUT_TYPES(s): FUNCTION = "thumbnail" CATEGORY = icons.get("Comfyroll/Graphics/Template") - def thumbnail(self, image, rescale_factor, max_columns): + def thumbnail(self, image, rescale_factor, grid_options): show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Other-Nodes#cr-seamless-checker" - result_images = [] outline_thickness = 0 - for img in image: - pil_img = tensor2pil(img) - original_width, original_height = pil_img.size - rescaled_img = apply_resize_image(tensor2pil(img), original_width, original_height, 8, "rescale", "false", rescale_factor, 256, "lanczos") - outlined_img = ImageOps.expand(rescaled_img, outline_thickness, fill="black") - result_images.append(outlined_img) + pil_img = tensor2pil(image) + original_width, original_height = pil_img.size + rescaled_img = apply_resize_image(tensor2pil(image), original_width, original_height, 8, "rescale", "false", rescale_factor, 256, "lanczos") + outlined_img = ImageOps.expand(rescaled_img, outline_thickness, fill="black") + + max_columns = int(grid_options[0]) + repeat_images = [outlined_img] * max_columns ** 2 - combined_image = make_grid_panel(result_images, max_columns) + combined_image = make_grid_panel(repeat_images, max_columns) images_out = pil2tensor(combined_image) # based on ETN_SendImageWebSocket diff --git a/nodes/nodes_list.py b/nodes/nodes_list.py index 23b9ada..7eb02ad 100644 --- a/nodes/nodes_list.py +++ b/nodes/nodes_list.py @@ -844,8 +844,9 @@ def cycle(self, values, repeats, loops=1): "CR Simple List": CR_SimpleList, "CR Load Image List": CR_LoadImageList, "CR Load Image List Plus": CR_LoadImageListPlus, - "CR Load GIF As List": CR_LoadGIFAsList, - "CR Float Range List": CR_FloatRangeList, + "CR Load GIF As List": CR_LoadGIFAsList, + "CR Float Range List": CR_FloatRangeList, + "CR Integer Range List": CR_FloatRangeList, "CR Load Text List": CR_LoadTextList, "CR Font File List": CR_FontFileList, "CR Binary To Bit List": CR_BinaryToBitList, @@ -854,7 +855,6 @@ def cycle(self, values, repeats, loops=1): ### List Utils "CR Batch Images From List": CR_MakeBatchFromImageList, "CR Intertwine Lists" : CR_IntertwineLists, - "CR Loop List": CR_LoopList, "CR Repeater": CR_Repeater, "CR XY Product": CR_XYProduct, "CR Text List To String": CR_TextListToString, diff --git a/nodes/nodes_utils_other.py b/nodes/nodes_utils_other.py index 18917af..be415be 100644 --- a/nodes/nodes_utils_other.py +++ b/nodes/nodes_utils_other.py @@ -42,96 +42,6 @@ def clamp_value(self, a, range_min, range_max): return (a, show_help, ) -#---------------------------------------------------------------------------------------------------------------------# -class CR_SetValueOnBinary: - - @classmethod - def INPUT_TYPES(cls): - return { - "required": { - "binary": ("INT", {"default": 1, "min": 0, "max": 1, "forceInput": True}), - "value_if_1": ("FLOAT", {"default": 1, "min": -18446744073709551615, "max": 18446744073709551615}), - "value_if_0": ("FLOAT", {"default": 0, "min": -18446744073709551615, "max": 18446744073709551615}), - } - } - - RETURN_TYPES =("INT", "FLOAT", "STRING", ) - RETURN_NAMES =("INT", "FLOAT", "show_help", ) - FUNCTION = "set_value" - CATEGORY = icons.get("Comfyroll/Utils/Conditional") - - def set_value(self, binary, value_if_1, value_if_0): - - show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Other-Nodes#cr-set-value-on-boolean" - - if binary == 1: - return (int(value_if_1), value_if_1, show_help, ) - else: - return (int(value_if_0), value_if_0, show_help, ) - -#---------------------------------------------------------------------------------------------------------------------# -class CR_SetValueOnBoolean: - - @classmethod - def INPUT_TYPES(cls): - return { - "required": { - "boolean": ("BOOLEAN", {"default": True, "forceInput": True}), - "value_if_true": ("FLOAT", {"default": 1, "min": -18446744073709551615, "max": 18446744073709551615}), - "value_if_false": ("FLOAT", {"default": 0, "min": -18446744073709551615, "max": 18446744073709551615}), - } - } - - RETURN_TYPES =("INT", "FLOAT", "STRING", ) - RETURN_NAMES =("INT", "FLOAT", "show_help", ) - FUNCTION = "set_value" - CATEGORY = icons.get("Comfyroll/Utils/Conditional") - - def set_value(self, boolean, value_if_true, value_if_false): - - show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Other-Nodes#cr-set-value-on-boolean" - - if boolean == True: - return (int(value_if_true), value_if_true, show_help, ) - else: - return (int(value_if_false), value_if_false, show_help, ) - -#---------------------------------------------------------------------------------------------------------------------# -class CR_SetValueOnString: - - @ classmethod - def INPUT_TYPES(cls): - return { - "required": { - "text": ("STRING", {"multiline": False, "default": "", "forceInput": True}), - }, - "optional": { - "test_string": ("STRING", {"multiline": False, "default": ""}), - "value_if_true": ("STRING", {"multiline": False, "default": ""}), - "value_if_false": ("STRING", {"multiline": False, "default": ""}), - }, - } - - RETURN_TYPES = (any_type, "BOOLEAN", "STRING", ) - RETURN_NAMES = ("STRING", "BOOLEAN","show_help", ) - FUNCTION = "replace_text" - CATEGORY = icons.get("Comfyroll/Utils/Conditional") - - def replace_text(self, text, test_string, value_if_true, value_if_false): - - show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/List-Nodes#cr-set-value-on-string" - - if test_string in text: - # Test condition is true, replace with value_if_true - text_out = value_if_true - bool_out = True - else: - # Test condition is false, replace with value_if_false - text_out = value_if_false - bool_out = False - - return (text_out, bool_out, show_help) - #---------------------------------------------------------------------------------------------------------------------# class CR_IntegerMultipleOf: @@ -323,6 +233,98 @@ def set_switch(self, method): return (method, show_help, ) +#---------------------------------------------------------------------------------------------------------------------# +# Conditional Nodes +#---------------------------------------------------------------------------------------------------------------------# +class CR_SetValueOnBinary: + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "binary": ("INT", {"default": 1, "min": 0, "max": 1, "forceInput": True}), + "value_if_1": ("FLOAT", {"default": 1, "min": -18446744073709551615, "max": 18446744073709551615}), + "value_if_0": ("FLOAT", {"default": 0, "min": -18446744073709551615, "max": 18446744073709551615}), + } + } + + RETURN_TYPES =("INT", "FLOAT", "STRING", ) + RETURN_NAMES =("INT", "FLOAT", "show_help", ) + FUNCTION = "set_value" + CATEGORY = icons.get("Comfyroll/Utils/Conditional") + + def set_value(self, binary, value_if_1, value_if_0): + + show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Other-Nodes#cr-set-value-on-boolean" + + if binary == 1: + return (int(value_if_1), value_if_1, show_help, ) + else: + return (int(value_if_0), value_if_0, show_help, ) + +#---------------------------------------------------------------------------------------------------------------------# +class CR_SetValueOnBoolean: + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "boolean": ("BOOLEAN", {"default": True, "forceInput": True}), + "value_if_true": ("FLOAT", {"default": 1, "min": -18446744073709551615, "max": 18446744073709551615}), + "value_if_false": ("FLOAT", {"default": 0, "min": -18446744073709551615, "max": 18446744073709551615}), + } + } + + RETURN_TYPES =("INT", "FLOAT", "STRING", ) + RETURN_NAMES =("INT", "FLOAT", "show_help", ) + FUNCTION = "set_value" + CATEGORY = icons.get("Comfyroll/Utils/Conditional") + + def set_value(self, boolean, value_if_true, value_if_false): + + show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Other-Nodes#cr-set-value-on-boolean" + + if boolean == True: + return (int(value_if_true), value_if_true, show_help, ) + else: + return (int(value_if_false), value_if_false, show_help, ) + +#---------------------------------------------------------------------------------------------------------------------# +class CR_SetValueOnString: + + @ classmethod + def INPUT_TYPES(cls): + return { + "required": { + "text": ("STRING", {"multiline": False, "default": "", "forceInput": True}), + }, + "optional": { + "test_string": ("STRING", {"multiline": False, "default": ""}), + "value_if_true": ("STRING", {"multiline": False, "default": ""}), + "value_if_false": ("STRING", {"multiline": False, "default": ""}), + }, + } + + RETURN_TYPES = (any_type, "BOOLEAN", "STRING", ) + RETURN_NAMES = ("STRING", "BOOLEAN","show_help", ) + FUNCTION = "replace_text" + CATEGORY = icons.get("Comfyroll/Utils/Conditional") + + def replace_text(self, text, test_string, value_if_true, value_if_false): + + show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/List-Nodes#cr-set-value-on-string" + + if test_string in text: + # Test condition is true, replace with value_if_true + text_out = value_if_true + bool_out = True + else: + # Test condition is false, replace with value_if_false + text_out = value_if_false + bool_out = False + + return (text_out, bool_out, show_help) + #---------------------------------------------------------------------------------------------------------------------# class CR_SetSwitchFromString: @@ -373,14 +375,15 @@ def set_switch(self, text, switch_1="", switch_2="", switch_3="", switch_4=""): NODE_CLASS_MAPPINGS = { ### Utility Other "CR Value": CR_Value, - "CR Clamp Value": CR_ClampValue, - "CR Set Value On Boolean": CR_SetValueOnBoolean, - "CR Set Value On Binary": CR_SetValueOnBinary, - "CR Set Value on String": CR_SetValueOnString, + "CR Clamp Value": CR_ClampValue, "CR Integer Multiple": CR_IntegerMultipleOf, "CR Math Operation": CR_MathOperation, "CR Get Parameter From Prompt": CR_GetParameterFromPrompt, "CR Select Resize Method": CR_SelectResizeMethod, + ### Conditional Nodes + "CR Set Value On Boolean": CR_SetValueOnBoolean, + "CR Set Value On Binary": CR_SetValueOnBinary, + "CR Set Value on String": CR_SetValueOnString, "CR Set Switch From String": CR_SetSwitchFromString, } ''' diff --git a/workflows/Graphics/Layout/CR_Overlay_Transparent_Image_demo2.json b/workflows/Graphics/Layout/CR_Overlay_Transparent_Image_demo1.json similarity index 100% rename from workflows/Graphics/Layout/CR_Overlay_Transparent_Image_demo2.json rename to workflows/Graphics/Layout/CR_Overlay_Transparent_Image_demo1.json diff --git a/workflows/Graphics/Template/CR_Seamless_Checker_demo1.json b/workflows/Graphics/Template/CR_Seamless_Checker_demo1.json new file mode 100644 index 0000000..3113952 --- /dev/null +++ b/workflows/Graphics/Template/CR_Seamless_Checker_demo1.json @@ -0,0 +1,105 @@ +{ + "last_node_id": 22, + "last_link_id": 19, + "nodes": [ + { + "id": 16, + "type": "LoadImage", + "pos": [ + 240, + 380 + ], + "size": [ + 320, + 310 + ], + "flags": {}, + "order": 0, + "mode": 0, + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 19 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "MASK", + "type": "MASK", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "LoadImage", + "ttNbgOverride": { + "color": "#222", + "bgcolor": "#000", + "groupcolor": "#444" + } + }, + "widgets_values": [ + "noise_00229_.png", + "image" + ], + "color": "#222", + "bgcolor": "#000" + }, + { + "id": 22, + "type": "CR Seamless Checker", + "pos": [ + 630, + 380 + ], + "size": { + "0": 390, + "1": 590 + }, + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [ + { + "name": "image", + "type": "IMAGE", + "link": 19 + } + ], + "outputs": [ + { + "name": "show_help", + "type": "STRING", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "CR Seamless Checker" + }, + "widgets_values": [ + 0.5, + "6x6" + ], + "color": "#222", + "bgcolor": "#000" + } + ], + "links": [ + [ + 19, + 16, + 0, + 22, + 0, + "IMAGE" + ] + ], + "groups": [], + "config": {}, + "extra": {}, + "version": 0.4 +} \ No newline at end of file diff --git a/workflows/Graphics/Template/CR_Simple_Image_Compare_demo1.json b/workflows/Graphics/Template/CR_Simple_Image_Compare_demo1.json new file mode 100644 index 0000000..7df5e6f --- /dev/null +++ b/workflows/Graphics/Template/CR_Simple_Image_Compare_demo1.json @@ -0,0 +1,240 @@ +{ + "last_node_id": 6, + "last_link_id": 6, + "nodes": [ + { + "id": 6, + "type": "CR Color Tint", + "pos": [ + 820, + 550 + ], + "size": { + "0": 240, + "1": 130 + }, + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [ + { + "name": "image", + "type": "IMAGE", + "link": 6 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 5 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "show_help", + "type": "STRING", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "CR Color Tint", + "ttNbgOverride": { + "color": "#222", + "bgcolor": "#000", + "groupcolor": "#444" + } + }, + "widgets_values": [ + 0.5, + "lavender", + "#000000" + ], + "color": "#222", + "bgcolor": "#000" + }, + { + "id": 1, + "type": "LoadImage", + "pos": [ + 440, + 360 + ], + "size": { + "0": 310, + "1": 490 + }, + "flags": {}, + "order": 0, + "mode": 0, + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 1, + 6 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "MASK", + "type": "MASK", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "LoadImage", + "ttNbgOverride": { + "color": "#222", + "bgcolor": "#000", + "groupcolor": "#444" + } + }, + "widgets_values": [ + "8d0081e2f52a46148d4b2a0dda202056.png", + "image" + ], + "color": "#222", + "bgcolor": "#000" + }, + { + "id": 4, + "type": "PreviewImage", + "pos": [ + 1480, + 350 + ], + "size": { + "0": 760, + "1": 540 + }, + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 3 + } + ], + "properties": { + "Node name for S&R": "PreviewImage", + "ttNbgOverride": { + "color": "#222", + "bgcolor": "#000", + "groupcolor": "#444" + } + }, + "color": "#222", + "bgcolor": "#000" + }, + { + "id": 3, + "type": "CR Simple Image Compare", + "pos": [ + 1100, + 360 + ], + "size": { + "0": 340, + "1": 266 + }, + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "name": "image1", + "type": "IMAGE", + "link": 1 + }, + { + "name": "image2", + "type": "IMAGE", + "link": 5 + } + ], + "outputs": [ + { + "name": "image", + "type": "IMAGE", + "links": [ + 3 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "show_help", + "type": "STRING", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "CR Simple Image Compare", + "ttNbgOverride": { + "color": "#222", + "bgcolor": "#000", + "groupcolor": "#444" + } + }, + "widgets_values": [ + "Before", + "After", + 100, + "Roboto-Regular.ttf", + 70, + "normal", + 20 + ], + "color": "#222", + "bgcolor": "#000" + } + ], + "links": [ + [ + 1, + 1, + 0, + 3, + 0, + "IMAGE" + ], + [ + 3, + 3, + 0, + 4, + 0, + "IMAGE" + ], + [ + 5, + 6, + 0, + 3, + 1, + "IMAGE" + ], + [ + 6, + 1, + 0, + 6, + 0, + "IMAGE" + ] + ], + "groups": [], + "config": {}, + "extra": {}, + "version": 0.4 +} \ No newline at end of file