Color Decode
Synopsis
Processes and converts between different color format representations.
Schema
- color_decode:
field: <ident>
output_format: <string>
target_field: <string>
input_format: <string>
alpha: <number>
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 | Y | - | Target color format: hex , rgb , rgba , hsl , hsla , hsv , hsva , name , rgb_array , hsl_array , hsv_array |
target_field | N | Same as field | Target field to store converted color |
input_format | N | auto | Input color format: auto , hex , rgb , hsl , hsv , name |
alpha | N | 1.0 | Default alpha value for formats requiring transparency (0-1) |
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 |
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 advanced options like alpha channel handling, percentage-based RGB values, and shortened hex notation.
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... |
|
converts to uppercase hex: |
|
RGB to HSL with Alpha
Converting RGB to HSL with alpha channel... |
|
adds alpha and converts to HSLA: |
|
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: |
|