ComfyUI Node

Copy Subset

Slice a palette without touching the original

By ranska·Created about a year ago·Updated 7 months ago· 1
Copy Subset
  • palette
  • subset
start_index0
end_index3

Copy Subset is the scissors of the Pixel Palette Art pack. Give it a palette and an index range, and it hands back a brand-new palette containing only those colors. Index 0 to 3 inclusive? You get a 4-color palette. It's how you turn a 32-color skin ramp you loaded from somewhere into just the 5 highlight shades you actually want - without mutating the source.

The word "copy" matters more than it looks like it does. Every color is deep-copied into a fresh palette, so your original stays byte-identical and you can keep feeding it to other branches. That's the same non-destructive philosophy the whole pack follows, and it means you can build divergent palette experiments off one source and compare them side by side in Palette View. This is the classic "one palette, many variants" pattern the pack's example workflows lean on.

How it works

The node calls PixelPalette.copy_subset(start, end). The important detail is that both indices are inclusive. start_index=2, end_index=5 gives you 4 colors (indices 2, 3, 4, 5), not 3. Slicing mistakes are the #1 beginner error here, so count carefully - a palette of 8 colors takes indices 0–7.

Out-of-range behavior is graceful rather than crashy: if start > end or the bounds exceed the palette, the node returns a deep copy of the original palette and logs an error to the console. So a bad range won't throw and kill your workflow - but you also won't get a hint on screen. Check the terminal if a downstream node suddenly has the wrong color count.

Inputs and outputs

  • palette (PIXEL_PALETTE) - the source.
  • start_index (INT, default 0) - first index, inclusive.
  • end_index (INT, default 3) - last index, inclusive.

Output is subset, a new PIXEL_PALETTE. Wire it into Palette View to see it, Palette Formatter to export it, or Append Palette to combine a few slices back together.

Installing

One of sixteen nodes in the Pixel Palette Art pack - one install, all nodes. ComfyUI Manager → search "Pixel Palette Art", or:

cd ComfyUI/custom_nodes
git clone https://github.com/ranska/pixel_palette_art.git

Restart ComfyUI; it appears under pixel_art/palette. Dependency is only Pillow, which ComfyUI already has.

Common issues

The inclusive-index surprise is the main trap - it's easy to ask for 0..15 expecting 16 colors and get 16 (which is correct), or to ask for 0..16 and get 17. Keep the "inclusive both ends" rule in mind. Also remember indices start at 0, so start_index=1 skips the palette's first color.

Second gotcha: the result is invisible until you attach something to subset. This whole pack is "compute in, visualize out" - Copy Subset gives you data, and you need Palette View or a formatter to see it. If it looks like nothing happened, that's not a bug; it's the pack working as designed.

Categorypixel_art/palette

Inputs (3)

NameTypeDefaultDescription
palettePIXEL_PALETTEPalette source
start_indexINT00–255Index de début (inclusif)
end_indexINT30–255Index de fin (inclusif)

Outputs (1)

NameTypeDescription
subsetPIXEL_PALETTE