comfyui-palette-toolkit
Model-independent hex palette construction and perceptual image harmonization for ComfyUI.
ComfyUI Palette Toolkit
Model-independent color-palette utilities for ComfyUI.
Text encoders do not reliably understand values such as #66788C. This project turns hex palettes into actual pixels and perceptual image operations instead of merely translating the codes into color names.
Initial nodes
Hex Palette Builder
Accepts a list of RGB hex codes and returns:
- a true RGB palette swatch as a ComfyUI
IMAGE; - normalized
#RRGGBBtext; - JSON metadata for API workflows.
Palette Harmonizer
Pulls an input image toward the supplied palette using OKLab perceptual color distance. It supports soft attraction, chroma-only grading, and nearest-color quantization while optionally preserving source luminance.
Because the harmonizer consumes and emits ordinary images, it can be used with any model family:
Load Image → Palette Harmonizer → VAE Encode → I2I sampling
or:
VAE Decode → Palette Harmonizer → Save Image
The first arrangement lets the palette influence generation through the model's image pathway. The second provides deterministic finishing. A model-specific IPAdapter or style-reference path can also consume the palette image, but that integration is deliberately outside the core model-independent nodes.
Installation
Clone or copy this repository into ComfyUI/custom_nodes/ComfyUI-Palette-Toolkit, then restart ComfyUI. No additional package installation is required; the node uses the PyTorch already supplied by ComfyUI.
First experiment
Use a six-color palette, soft mode, 0.35 strength, 0.08 softness, and preserve luminance. Grade the I2I source before VAE Encode, then compare an unchanged seed at several denoise strengths.
Development
Dependency-free parser tests can be run from the repository root:
python -m unittest discover -s tests -v
Runtime image tests require the Python environment used by ComfyUI because the color processing operates on its PyTorch tensors.
Roadmap
- Generate palette maps with configurable spatial color proportions.
- Extract dominant palettes from reference images.
- Add masks and per-region palette assignments.
- Produce and apply reusable 3D LUTs.
- Add optional bridges for model-specific visual-conditioning systems.
- Explore differentiable palette guidance during sampling.
Design boundary
This project provides genuine pixel-level palette control. It does not claim that one universal conditioning object can plug directly into every diffusion architecture; those adapters remain model-specific.
License
MIT