diff --git a/__init__.py b/__init__.py index a49a6ff..66e11a3 100644 --- a/__init__.py +++ b/__init__.py @@ -20,7 +20,9 @@ from .show_int import ShowInt from .show_float import ShowFloat from .save_text import SaveText from .save_tmp_image import SaveTmpImage +from .save_image_path import SaveImagePath from .save_api_image import SaveApiImage +from .resize_image import ResizeImage from .loop_my_combos_samplers_schedulers import LoopCombosSamplersSchedulers # from .CUSTOM_STRING import CustomStringType @@ -37,7 +39,9 @@ NODE_CLASS_MAPPINGS = { "Bjornulf_ShowInt": ShowInt, "Bjornulf_ShowFloat": ShowFloat, "Bjornulf_SaveText": SaveText, + "Bjornulf_ResizeImage": ResizeImage, "Bjornulf_SaveTmpImage": SaveTmpImage, + "Bjornulf_SaveImagePath": SaveImagePath, "Bjornulf_SaveApiImage": SaveApiImage, "Bjornulf_CombineTexts": CombineTexts, "Bjornulf_LoopTexts": LoopTexts, @@ -59,6 +63,8 @@ NODE_DISPLAY_NAME_MAPPINGS = { "Bjornulf_ShowText": "👁 Show (Text)", "Bjornulf_ShowInt": "👁 Show (Int)", "Bjornulf_ShowFloat": "👁 Show (Float)", + "Bjornulf_ResizeImage": "📏 Resize Image", + "Bjornulf_SaveImagePath": "🖼 Save Image (exact path, exact name)", "Bjornulf_SaveTmpImage": "🖼 Save Image (tmp_api.png)", "Bjornulf_SaveApiImage": "🖼 Save Image (API_IMAGES/00001.png...)", "Bjornulf_SaveText": "💾 Save Text", #Make SaveCharacter, SaveLocation, SaveCamera, SaveAction, SaveClothes, SaveEmotion... diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..8485826 Binary files /dev/null and b/__pycache__/__init__.cpython-312.pyc differ diff --git a/__pycache__/combine_texts.cpython-312.pyc b/__pycache__/combine_texts.cpython-312.pyc new file mode 100644 index 0000000..96d59e3 Binary files /dev/null and b/__pycache__/combine_texts.cpython-312.pyc differ diff --git a/__pycache__/create_video.cpython-312.pyc b/__pycache__/create_video.cpython-312.pyc new file mode 100644 index 0000000..50f9ab0 Binary files /dev/null and b/__pycache__/create_video.cpython-312.pyc differ diff --git a/__pycache__/loop_basic_batch.cpython-312.pyc b/__pycache__/loop_basic_batch.cpython-312.pyc new file mode 100644 index 0000000..77d4794 Binary files /dev/null and b/__pycache__/loop_basic_batch.cpython-312.pyc differ diff --git a/__pycache__/loop_float.cpython-312.pyc b/__pycache__/loop_float.cpython-312.pyc new file mode 100644 index 0000000..aa6b851 Binary files /dev/null and b/__pycache__/loop_float.cpython-312.pyc differ diff --git a/__pycache__/loop_integer.cpython-312.pyc b/__pycache__/loop_integer.cpython-312.pyc new file mode 100644 index 0000000..f9243e9 Binary files /dev/null and b/__pycache__/loop_integer.cpython-312.pyc differ diff --git a/__pycache__/loop_my_combos_samplers_schedulers.cpython-312.pyc b/__pycache__/loop_my_combos_samplers_schedulers.cpython-312.pyc new file mode 100644 index 0000000..d29a9aa Binary files /dev/null and b/__pycache__/loop_my_combos_samplers_schedulers.cpython-312.pyc differ diff --git a/__pycache__/loop_samplers.cpython-312.pyc b/__pycache__/loop_samplers.cpython-312.pyc new file mode 100644 index 0000000..1089412 Binary files /dev/null and b/__pycache__/loop_samplers.cpython-312.pyc differ diff --git a/__pycache__/loop_schedulers.cpython-312.pyc b/__pycache__/loop_schedulers.cpython-312.pyc new file mode 100644 index 0000000..d88b832 Binary files /dev/null and b/__pycache__/loop_schedulers.cpython-312.pyc differ diff --git a/__pycache__/loop_texts.cpython-312.pyc b/__pycache__/loop_texts.cpython-312.pyc new file mode 100644 index 0000000..80b8520 Binary files /dev/null and b/__pycache__/loop_texts.cpython-312.pyc differ diff --git a/__pycache__/ollama.cpython-312.pyc b/__pycache__/ollama.cpython-312.pyc new file mode 100644 index 0000000..34ab897 Binary files /dev/null and b/__pycache__/ollama.cpython-312.pyc differ diff --git a/__pycache__/random_model_clip_vae.cpython-312.pyc b/__pycache__/random_model_clip_vae.cpython-312.pyc new file mode 100644 index 0000000..3e01784 Binary files /dev/null and b/__pycache__/random_model_clip_vae.cpython-312.pyc differ diff --git a/__pycache__/random_texts.cpython-312.pyc b/__pycache__/random_texts.cpython-312.pyc new file mode 100644 index 0000000..fbe1da4 Binary files /dev/null and b/__pycache__/random_texts.cpython-312.pyc differ diff --git a/__pycache__/resize_image.cpython-312.pyc b/__pycache__/resize_image.cpython-312.pyc new file mode 100644 index 0000000..f7836e1 Binary files /dev/null and b/__pycache__/resize_image.cpython-312.pyc differ diff --git a/__pycache__/save_api_image.cpython-312.pyc b/__pycache__/save_api_image.cpython-312.pyc new file mode 100644 index 0000000..5aa1507 Binary files /dev/null and b/__pycache__/save_api_image.cpython-312.pyc differ diff --git a/__pycache__/save_image_path.cpython-312.pyc b/__pycache__/save_image_path.cpython-312.pyc new file mode 100644 index 0000000..eb18810 Binary files /dev/null and b/__pycache__/save_image_path.cpython-312.pyc differ diff --git a/__pycache__/save_text.cpython-312.pyc b/__pycache__/save_text.cpython-312.pyc new file mode 100644 index 0000000..8b91d96 Binary files /dev/null and b/__pycache__/save_text.cpython-312.pyc differ diff --git a/__pycache__/save_tmp_image.cpython-312.pyc b/__pycache__/save_tmp_image.cpython-312.pyc new file mode 100644 index 0000000..4908623 Binary files /dev/null and b/__pycache__/save_tmp_image.cpython-312.pyc differ diff --git a/__pycache__/show_float.cpython-312.pyc b/__pycache__/show_float.cpython-312.pyc new file mode 100644 index 0000000..1316901 Binary files /dev/null and b/__pycache__/show_float.cpython-312.pyc differ diff --git a/__pycache__/show_int.cpython-312.pyc b/__pycache__/show_int.cpython-312.pyc new file mode 100644 index 0000000..b0875d9 Binary files /dev/null and b/__pycache__/show_int.cpython-312.pyc differ diff --git a/__pycache__/show_text.cpython-312.pyc b/__pycache__/show_text.cpython-312.pyc new file mode 100644 index 0000000..4b3ce47 Binary files /dev/null and b/__pycache__/show_text.cpython-312.pyc differ diff --git a/__pycache__/video_pingpong.cpython-312.pyc b/__pycache__/video_pingpong.cpython-312.pyc new file mode 100644 index 0000000..37d6f69 Binary files /dev/null and b/__pycache__/video_pingpong.cpython-312.pyc differ diff --git a/__pycache__/write_image_allinone.cpython-312.pyc b/__pycache__/write_image_allinone.cpython-312.pyc new file mode 100644 index 0000000..39159a0 Binary files /dev/null and b/__pycache__/write_image_allinone.cpython-312.pyc differ diff --git a/__pycache__/write_image_character.cpython-312.pyc b/__pycache__/write_image_character.cpython-312.pyc new file mode 100644 index 0000000..d9ca4f2 Binary files /dev/null and b/__pycache__/write_image_character.cpython-312.pyc differ diff --git a/__pycache__/write_image_characters.cpython-312.pyc b/__pycache__/write_image_characters.cpython-312.pyc new file mode 100644 index 0000000..0c934d9 Binary files /dev/null and b/__pycache__/write_image_characters.cpython-312.pyc differ diff --git a/__pycache__/write_image_environment.cpython-312.pyc b/__pycache__/write_image_environment.cpython-312.pyc new file mode 100644 index 0000000..f9d18f8 Binary files /dev/null and b/__pycache__/write_image_environment.cpython-312.pyc differ diff --git a/__pycache__/write_text.cpython-312.pyc b/__pycache__/write_text.cpython-312.pyc new file mode 100644 index 0000000..239937b Binary files /dev/null and b/__pycache__/write_text.cpython-312.pyc differ diff --git a/resize_image.py b/resize_image.py new file mode 100644 index 0000000..b62eec1 --- /dev/null +++ b/resize_image.py @@ -0,0 +1,43 @@ +import numpy as np +import torch +from PIL import Image + +class ResizeImage: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "image": ("IMAGE", {}), + "width": ("INT", {"default": 256}), + "height": ("INT", {"default": 256}), + } + } + + FUNCTION = "resize_image" + RETURN_TYPES = ("IMAGE",) + OUTPUT_NODE = True + CATEGORY = "Bjornulf" + + def resize_image(self, image, width=256, height=256): + # Convert the image from ComfyUI format to PIL Image + i = 255. * image.cpu().numpy() + + # Reshape the image if it's not in the expected format, remove any leading dimensions of size 1 + if i.ndim > 3: + i = np.squeeze(i) + # Ensure the image is 3D (height, width, channels) + if i.ndim == 2: + i = i[:, :, np.newaxis] # Add a channel dimension if it's missing + + img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8)) + + # Resize the image + img_resized = img.resize((width, height), Image.LANCZOS) + + # Convert the PIL image back to numpy array + img_resized_np = np.array(img_resized).astype(np.float32) / 255.0 + + # Assuming ComfyUI format needs the image back in tensor format, convert it back + img_resized_tensor = torch.tensor(img_resized_np) + + return (img_resized_tensor, ) diff --git a/save_image_path.py b/save_image_path.py new file mode 100644 index 0000000..e475d4a --- /dev/null +++ b/save_image_path.py @@ -0,0 +1,39 @@ +import os +import numpy as np +from PIL import Image + +class SaveImagePath: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "image": ("IMAGE", {"forceInput": True}), + "path": ("STRING", {"default":"./output/default.png"}), # Add path input + } + } + + FUNCTION = "save_image_path" + RETURN_TYPES = () + OUTPUT_NODE = True + CATEGORY = "Bjornulf" + + def save_image_path(self, image, path): + # Ensure the output directory exists + os.makedirs(os.path.dirname(path), exist_ok=True) + + # Convert the image from ComfyUI format to PIL Image + i = 255. * image.cpu().numpy() + + # Reshape the image if it's not in the expected format, remove any leading dimensions of size 1 + if i.ndim > 3: + i = np.squeeze(i) + # Ensure the image is 3D (height, width, channels) + if i.ndim == 2: + i = i[:, :, np.newaxis] # Add a channel dimension if it's missing + + img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8)) + + # Save the image, overwriting if it exists + img.save(path, format="PNG") + + return ()