# Color Transform Processor
## Overview
The **Color Transform Processor** applies color-based effects to an image. It can perform a variety of color transformations such as inverting colors, applying a color tint (colorize), converting the image to grayscale, and applying a sepia tone. This processor is designed to work on the entire image or selected areas based on a mask.
---
## Example Usage
```yaml
- processor:
processor: "color_transform"
inputs:
source: "input/image.png" # Input image (RGBA)
mask: "input/mask.png" # (Optional) Grayscale mask to limit the effect to a specific area
params:
effect: "invert" # Effect to apply. Options: "invert", "colorize", "grayscale", "sepia"
# Parameters specific to "colorize" effect:
color: "rgba(255, 0, 0, 0.5)" # Color in RGBA (only used if effect is "colorize")
intensity: 0.75 # Intensity of the effect (0.0 to 1.0)
outputs:
target: "output/colored.png" # Output PNG image after applying the effect
```
---
## Inputs
| **Key** | **Required** | **Description** |
| -------- | -----------: | ---------------------------------------------------------------------------- |
| `source` | **Yes** | Filepath to the input image (RGBA). |
| `mask` | | Filepath to the grayscale mask image. Limits effect application if provided. |
---
## Params
| **Key** | **Type** | **Default** | **Description** |
| ------------ | -------- | ----------- | ---------------------------------------------------------------------------------------------- |
| `effect` | `str` | `"invert"` | The color transformation to apply. Options include "invert", "colorize", "grayscale", "sepia". |
| `tint_color` | `str` | _N/A_ | Tint color in RGBA for the "colorize" effect. |
| `intensity` | `float` | `1.0` | Intensity of the effect, ranging from 0.0 (no effect) to 1.0 (full effect). |
---
## Outputs
| **Key** | **Required** | **Description** |
| -------- | -----------: | ----------------------------------------------------------------------- |
| `target` | **Yes** | Filepath to the output PNG image with the color transformation applied. |
---
## Processing Details
1. **Input Loading:**
- Load the source image in RGBA.
- Optionally load a grayscale mask if provided, to restrict the effect to specific areas.
2. **Effect Application:**
- **Invert:** Reverse the color values of each pixel.
- **Colorize:** Blend the original colors with the specified `tint_color` based on the `intensity` parameter.
- **Grayscale:** Convert the image to grayscale.
- **Sepia:** Apply a sepia tone transformation to give the image a warm, vintage look.
- The processor uses the `intensity` value to adjust the strength of the effect.
3. **Mask Handling (Optional):**
- If a mask is provided, limit the effect application to the regions where the mask is non-zero.
4. **Output Generation:**
- Generate the processed image and save it as a PNG in RGBA format to the specified output target.