94886fdf49da99ae8bcc1878b2a9a5f60203cca7
ComfyUI-Koolook-Nodes
This repository provides custom nodes for ComfyUI tailored for VFX and AI image/video generation workflows. It includes:
- Wan22EasyPrompt: A dynamic prompt builder node that loads input fields and dropdown options from a
config.jsonfile. Inspired by Wan 2.2 parameters (e.g., light sources, lighting types, time of day), it generates comma-separated prompt strings for use in workflows like structured prompts with nodes such as PromptJSON. - ImageAspect: An image resizing node that adjusts images based on a base dimension (width or height), aspect ratio (e.g., "16:9"), and ensures dimensions are divisible by a specified value (e.g., 32 for model compatibility). Supports stretch, letterbox, or pillarbox modes with padding and cropping options. Ideal for preparing images in VFX pipelines.
The code for the ImageAspect node is inspired by the Resize Image V2 node from ComfyUI-KJNodes (reference file: image_nodes.py, available at https://github.com/kijai/ComfyUI-KJNodes).
Features
- Dynamic Inputs for Prompts: Fields and dropdowns in Wan22EasyPrompt are defined in
config.json, allowing easy customization without code changes. - Image Resizing with Aspect Control: ImageAspect ensures precise resolutions for AI models, with options for keep_proportion preservation, padding colors, and device selection (CPU/CUDA).
- Startup Loading: Nodes load configurations at ComfyUI launch; edit
config.jsonand restart to update. - Output Formatting: Wan22EasyPrompt outputs comma-separated strings (skipping "none"), compatible with prompt builders. ImageAspect outputs resized images, masks, and width/height integers.
- Error Handling: Fallbacks for missing/invalid JSON in Wan22EasyPrompt; validation for aspect ratios and divisibility in ImageAspect.
- Compatibility: Works with ComfyUI-Manager for easy installation via Git URL. No additional dependencies beyond standard Python and ComfyUI libraries.
Installation
Via ComfyUI-Manager (Recommended)
- Open ComfyUI and access the Manager interface.
- Go to "Install Custom Nodes" > "Install via Git URL".
- Paste the repository URL:
https://github.com/malkuthro/ComfyUI-Koolook.git. - Install and restart ComfyUI.
- The nodes will appear:
- "Wan 2.2 Easy Prompt" under "Koolook/Wan_Video".
- "Image Aspect" under "Koolook/Image".
Manual Installation
- Clone this repository into your
ComfyUI/custom_nodes/directory:git clone https://github.com/malkuthro/ComfyUI-Koolook.git - Ensure
__init__.pyandconfig.jsonare in the cloned folder. - Restart ComfyUI.
No additional dependencies required beyond standard Python libraries.
Usage
Wan22EasyPrompt
- Add the "Wan 2.2 Easy Prompt" node to your workflow.
- Select options from the dropdowns (e.g., Light Source: "Sunny lighting", Lighting Type: "Soft lighting").
- Optionally connect a CLIP for conditioning output.
- Connect the STRING outputs (combined_prompt or fields_only) to a prompt input, such as the "prompt" slot in the PromptJSON node (from NeuralSamurAI/ComfyUI-PromptJSON).
- To customize fields:
- Edit
config.json(see example below). - Restart ComfyUI to apply changes.
- Edit
Example config.json
This is the default configuration based on Wan 2.2 parameters:
{
"category": "Koolook/Wan_Video",
"node_name": "Wan_2.2",
"fields": [
{
"name": "light_source",
"type": "combo",
"options": ["none", "Sunny lighting", "Artificial lighting", "Moonlighting", "Practical lighting", "Firelighting", "Fluorescent lighting", "Overcast lighting", "Mixed lighting"],
"default": "none"
},
{
"name": "lighting_type",
"type": "combo",
"options": ["none", "Soft lighting", "Hard lighting", "Top lighting", "Side lighting", "Underlighting", "Edge lighting", "Silhouette lighting", "Low contrast lighting", "High contrast lighting"],
"default": "none"
},
// ... (additional fields like time_of_day, shot_size, etc.)
],
"output_type": "STRING"
}
ImageAspect
- Add the "Image Aspect" node to your workflow.
- Connect an IMAGE (and optional MASK) input.
- Set the base dimension (Width or Height), base size, aspect ratio (e.g., "16:9" for landscape, "9:16" for portrait), and other options like keep_proportion (stretch, letterbox, pillarbox), pad_color (e.g., "0, 0, 0" for black), crop_position, divisible_by, and device.
- Connect the outputs: IMAGE and MASK for further processing, INT width/height for resolution-aware nodes.
- Useful for VFX: Ensures model-compatible sizes (e.g., divisible by 32) while maintaining aspect ratios.
Node Code Overview
The core logic is in __init__.py:
- Wan22EasyPrompt: Loads
config.jsonat import time, builds inputs dynamically (combos for dropdowns, strings for text), and formats selections into prompt strings with optional CLIP conditioning. - ImageAspect: Parses aspect ratios, computes divisible dimensions, resizes with common_upscale, and handles padding/cropping. Inspired by Resize Image V2 from ComfyUI-KJNodes.
For advanced customizations (e.g., different output formats or additional resize modes), modify the execute or adjust_to_aspect methods.
Troubleshooting
- ComfyUI Won't Start: Check console logs for errors (run
python main.py). Common: Missingconfig.jsonor invalid JSON—use a validator like jsonlint.com. - No Fields Visible in Wan22EasyPrompt: Indicates JSON load failure; the node falls back to empty inputs.
- Errors in ImageAspect: Ensure aspect ratio is "w:h" format, divisible_by >=1, and pad_color is "r, g, b" floats (0.0-1.0).
- Updates: Pull latest from GitHub and restart.
Credits
- Based on ComfyUI custom node examples.
- Parameters for Wan22EasyPrompt derived from Wan 2.2 docs (https://alidocs.dingtalk.com/i/nodes/EpGBa2Lm8aZxe5myC99MelA2WgN7R35y).
- ImageAspect inspired by ComfyUI-KJNodes (https://github.com/kijai/ComfyUI-KJNodes), specifically the Resize Image V2 node in image_nodes.py.
- Compatible with nodes like PromptJSON for LLM workflows.
License
MIT License. Feel free to use, modify, and distribute.
Languages
Python
67.9%
JavaScript
30.3%
HTML
1%
CSS
0.5%
Shell
0.2%
Other
0.1%