Skip to main content
Version: 1.4.0

Color Decode

Parse Data Analysis

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:

FieldRequiredDefaultDescription
fieldY-Source field containing color data to convert
output_formatY-Target color format: hex, rgb, rgba, hsl, hsla, hsv, hsva, name, rgb_array, hsl_array, hsv_array
target_fieldNSame as fieldTarget field to store converted color
input_formatNautoInput color format: auto, hex, rgb, hsl, hsv, name
alphaN1.0Default alpha value for formats requiring transparency (0-1)
uppercaseNfalseOutput hex values in uppercase
short_hexNfalseOutput 3-character hex when possible (e.g., "#f00" vs "#ff0000")
percent_rgbNfalseOutput RGB values as percentages instead of 0-255
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if conversion fails
ignore_missingNfalseSkip processing if referenced field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-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.

note

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.

warning

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...

{
"color_value": "#ff5733"
}
- color_decode:
field: color_value
output_format: rgb
target_field: rgb_color

converts to RGB notation:

{
"color_value": "#ff5733",
"rgb_color": "rgb(255, 87, 51)"
}

Named Color to Hex

Converting color name to hexadecimal...

{
"ui_color": "red"
}
- color_decode:
field: ui_color
output_format: hex
uppercase: true

converts to uppercase hex:

{
"ui_color": "red",
"ui_color": "#FF0000"
}

RGB to HSL with Alpha

Converting RGB to HSL with alpha channel...

{
"theme_color": "rgb(100, 150, 200)"
}
- color_decode:
field: theme_color
output_format: hsla
alpha: 0.8
target_field: hsl_color

adds alpha and converts to HSLA:

{
"theme_color": "rgb(100, 150, 200)",
"hsl_color": "hsla(210, 48%, 59%, 0.8)"
}

Color to Array Format

Converting color to numerical array...

{
"brand_color": "#3498db"
}
- color_decode:
field: brand_color
output_format: rgb_array
target_field: color_values

outputs RGB as array:

{
"brand_color": "#3498db",
"color_values": [52, 152, 219]
}

Percentage RGB Output

Converting to RGB with percentage values...

{
"accent_color": "#80ff80"
}
- color_decode:
field: accent_color
output_format: rgb
percent_rgb: true
target_field: percent_color

outputs RGB as percentages:

{
"accent_color": "#80ff80",
"percent_color": "rgb(50%, 100%, 50%)"
}