Color Decode
Synopsis
Processes and converts between different color format representations.
Schema
- color_decode:
field: <ident>
output_format: <string>
target_field: <ident>
input_format: <string>
uppercase: <boolean>
short_hex: <boolean>
percent_rgb: <boolean>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | - | Source field containing color data to convert |
output_format | N | hex | Target color format: hex, rgb, rgba, hsl, hsla, hsv, hsva, name, rgb_array, hsl_array, hsv_array. An omitted or unrecognised value falls back to hex rather than failing |
target_field | N | Same as field | Target field to store the converted color |
input_format | N | auto | Input color format: auto, hex, rgb, hsl, hsv, name |
uppercase | N | false | Output hex values in uppercase |
short_hex | N | false | Output 3-character hex when possible (e.g., "#f00" vs "#ff0000") |
percent_rgb | N | false | Output RGB values as percentages instead of 0-255 |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if conversion fails |
ignore_missing | N | false | Skip processing if referenced field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
disabled | N | false | When true, the processor is skipped and the event continues to the next one. Lets you take a processor out of the path without removing its configuration |
Details
Converts color values between various common color formats including hex, RGB, HSL, HSV, and named colors. The processor can automatically detect the input format or work with explicitly specified formats.
The processor supports both simple color conversion and options such as percentage-based RGB values and shortened hex notation.
Alpha is read from the input, never configured. A color written with an alpha component — rgba(), hsla(), or 8-digit hex — carries it through; anything else is fully opaque. An a-suffixed output_format (rgba, hsla, hsva) always emits the component, so an opaque input renders as 1.00.
When input_format is set to "auto", the processor attempts to automatically detect the color format based on the input string pattern. This works with most common color representations.
The output format determines the structure of the converted color value. Array formats (like rgb_array) return numerical arrays, while string formats return formatted color strings.
If the input color cannot be parsed or converted to the specified output format, the processor will fail unless ignore_failure is set to true. Invalid color names or malformed color values will trigger errors.
Examples
Hex to RGB Conversion
Converting hexadecimal color to RGB format... | |
converts to RGB notation: | |
Named Color to Hex
Converting color name to hexadecimal... | |
replacing the source value, since | |
RGB to HSLA
Converting to an alpha-carrying format... | |
the input carries no alpha, so the component is emitted as fully opaque: | |
Color to Array Format
Converting color to numerical array... | |
outputs RGB as array: | |
Percentage RGB Output
Converting to RGB with percentage values... | |
outputs RGB as percentages: | |