Imgix APIsRendering APIBackgroundColor Key Mode

Color Key Mode

colorkey-mode

The colorkey-mode parameter chooses how colorkey measures how close a pixel is to the key color. It has no effect without colorkey.

ValueMeasuresUse for
color (default)Red, green and blue, including brightnessWhite, gray, black and other solid backgrounds
chromaColor only, ignoring brightnessGreen and blue screens with uneven lighting

chroma matches the method and defaults of video-mark-chromakey in the Video API, so a color key behaves the same on images and video. Switching modes also changes the defaults of the other color key parameters:

Parametercolor defaultchroma default
colorkey-tol2054.09
colorkey-feather3018.03
colorkey-defringe10.5

In chroma mode the tolerance is much wider, because ignoring brightness means a green screen’s lit and shadowed areas all have to fall inside one range. The feather and defringe defaults are narrower, since a saturated key separates from the subject more cleanly and needs less edge correction.

When Not to Use Chroma Mode

Because chroma ignores brightness, it cannot tell white, gray and black apart, and it treats every low-saturation color as close to a gray or muted key. Keying a white background in chroma mode removes the whole image. Use the default color mode for neutral and muted backgrounds.

Saturated subject colors near the key hue can also be partly removed in chroma mode. For example, a cyan subject is close to a green key. Lower colorkey-tol if that happens.

colorkeymode is accepted as an alias.

colorkey-mode=color (default)
sandbox-demo
colorkey-mode=chroma: the muted blue key also removes the subject
sandbox-demo