Nodes/ComfyUI-CustomNodePacks/Color Space Convert (MEC)
ComfyUI Node

Color Space Convert (MEC)

The four-color-space converter for people who actually composite — sRGB, linear, Rec.709, ACEScg

By Code2Collapse·Created 6 months ago·Updated a day ago· 52
Color Space Convert (MEC)
  • image
  • image
src_spacesrgb
dst_spacelinear

Here's the problem this node solves in one sentence: blending two sRGB images in the gamma-encoded domain makes dark halos, and every compositor has seen it. ColorSpaceConvertMEC moves an IMAGE between the four spaces a real VFX pipeline actually uses - sRGB, linear, Rec.709, and ACEScg - so you can decode your render to linear, do your math, and encode back at the end. It's the same job as the pack's newer C2CColorSpaceConvert, but this one's tuned for the broadcast/video gamuts the older node doesn't touch.

The KB's post-processing doc nails the context: ComfyUI hands you 8-bit-ish sRGB tensors, but a Nuke-style pipeline works in scene-linear float with a wide gamut, and handing a gamma-encoded PNG to a comp blows out every merge. This node is the cheap way to stay honest about what your pixels are encoded as.

How it works

The implementation lives in nodes/color_science.py alongside the pack's .cube LUT parser, and the conversion is a two-hop path through linear: decode your source space to linear light, then encode to the destination. sRGB↔linear uses the standard piecewise transfer curve; Rec.709 uses the broadcast transfer function; ACEScg uses the ACES AP1 primaries. Because it goes through linear, the conversions compose correctly - sRGB→ACEScg is the same as sRGB→linear→ACEScg, and you never get double-gamma drift.

The inputs

  • image - the input batch.
  • src_space - srgb, linear, rec709, or acescg. Default srgb.
  • dst_space - same four, default linear.

Output is a single image.

Installing it

Part of Code2Collapse/ComfyUI-CustomNodePacks. ComfyUI Manager → search "CustomNodePacks", or:

cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git

Restart ComfyUI. Pure tensor math - no models, no downloads, nothing extra to install. (Same rule as every node in this pack: don't blanket pip install -r requirements.txt over ComfyUI's own torch/numpy.)

Gotchas

The honest caveats are the usual color-science ones. First, if your source was actually encoded with a transfer function that isn't one of these four - say, a camera's log curve - this node won't fix it; convert at the camera flavor first (the pack's C2CColorSpaceConvert covers Log C3 for that case). Second, converting sRGB→linear→sRGB on an 8-bit image is lossy; keep your working pixels in linear float for as long as you can and only encode once at the end. And third - the one that trips people - ACEScg is a wide-gamut working space, so encoding to it then displaying without a tonemap will look washed out. Use it for compositing and ACES-friendly outputs, not for a final JPEG. Get those right and this is the node that makes your blends stop looking muddy.

CategoryMaskEditControl/Color

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
src_spaceCOMBOsrgb4 options: srgb, linear, rec709, acescg
dst_spaceCOMBOlinear4 options: srgb, linear, rec709, acescg

Outputs (1)

NameTypeDescription
imageIMAGE