Nodes/ComfyUI-SmartImageTools/Smart Preview Palette
ComfyUI Node

Smart Preview Palette

A color strip that turns into a swatch grid on the node

By slvslvslv·Created about a year ago·Updated 25 days ago· 2
Smart Preview Palette
  • palette_image

    Smart Preview Palette is a viewer node with a party trick: feed it a palette image and it renders the colors as a neat grid of swatches right on the node face, instead of dumping an image you have to squint at or open. It's the "look at what palette I got" companion to the palette-generation nodes in this pack, and it makes palette work feel way less abstract.

    How it works

    The node expects a palette image - specifically an image that's one pixel tall. The Python side reads each pixel along the row, converts it to a #RRGGBB hex string, and hands that list to the front end. The bundled JavaScript then draws a grid of color squares sized to fit the node, centered and labeled. Resize the node and the swatches reflow to fit.

    Mechanically there are two things to feed it:

    • A SmartImagePaletteExtract output - the strip of dominant colors pulled out of an image (this pack's palette extractor produces exactly the 1×N format this node wants).
    • A SmartImagePaletteConvert output if it's wired to write a palette image out.

    The "image" port is named palette_image and it's the only input. There are no outputs - this is an output/display node (is_output_node: true), so it sits at the end of a branch purely to show you something.

    Where it plugs in

    The realistic workflow is palette extraction for art direction: generate an image, extract its palette, preview the swatches here to sanity-check the color story before you act on it. Because it's a pure display node, you can drop it on a side branch without disturbing the main graph - the preview doesn't need to be on the critical path, and ComfyUI will run it alongside your other outputs.

    The palette_image must be 1 pixel tall for the swatch read to do anything useful. The code only iterates the width when the height is exactly 1 - anything else comes back empty, so a normal 512×512 image is the wrong input. Feed it the palette strip, not the source image.

    Installing it

    Part of ComfyUI-SmartImageTools:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/slvslvslv/ComfyUI-SmartImageTools
    pip install -r ComfyUI-SmartImageTools/requirements.txt
    

    Restart ComfyUI, or search "ComfyUI-SmartImageTools" in ComfyUI Manager. The pack's real requirements.txt pulls in scikit-learn, scikit-image, numpy, Pillow, opencv-python, and numba - heavier than the README lists, and the first start after installing is slow while those build.

    Gotchas

    • Feed it a 1-pixel-tall strip, not a photo. This is the #1 misuse, and the failure mode is silent - an empty grid.
    • The swatch grid is a display artifact, not an image you can route onward. If you want the palette as an image for the rest of your workflow, use the extract/convert node's image output; this node is for your eyes only.
    • The palette strip needs the colors in a row you actually care about. If your extractor returns a 2-row strip, reduce it first or the node shows nothing.

    It's a small, opinionated preview widget - the kind of thing that saves you from eyeballing a tiny palette thumbnail in the corner of the preview pane. For anyone doing palette-driven work, it's the difference between "I extracted 8 colors" and "oh, that's the mood."

    CategorySmartImageTools

    Inputs (1)

    NameTypeDefaultDescription
    palette_imageIMAGE

    Outputs (0)

    No outputs