# **Convert Image Processor**
## **Overview**
The **Convert Image** processor (`convert_image`) loads an input image and **re-encodes** or **saves** it in a **different format** (e.g., PNG → JPEG). This is useful for normalizing output formats across your pipeline or changing the compression/quality settings. Unlike more complex color or filter operations, **Convert Image** focuses **only on format conversion**.
---
## **Example Usage**
```yaml
- processor:
processor: "convert_image"
inputs:
source: "output/input.png"
params:
quality: "85" # (Optional) JPEG compression level
outputs:
target: "output/output.jpg"
```
**Explanation**:
1. **`source`**: The path to the **input** image.
2. **`quality`**: If you are saving to a format that supports compression (e.g., JPEG), this sets the compression level.
3. **`target`**: The **converted** file. The format is inferred from the file extension (e.g., `.jpg`, `.png`, etc.).
---
## **Inputs**
| **Key** | **Required** | **Description** |
| -------- | -----------: | ------------------------------------------------------------ |
| `source` | **Yes** | A file path referencing the **input** image to be converted. |
_(The processor loads from your storage system using this path.)_
---
## **Params**
_(Optional parameters for controlling certain format details.)_
| **Key** | **Type** | **Required** | **Default** | **Description** |
| --------- | -------: | -----------: | ----------: | ----------------------------------------------------------------------------------------------------------------------------------- |
| `quality` | `int` | | `85` | (JPEG/WEBP/etc.) If the target extension is a format that supports compression/quality, sets the compression level (e.g., `0-100`). |
---
## **Outputs**
| **Key** | **Required** | **Description** |
| -------- | -----------: | ------------------------------------------------------------------------------------------------------------------------------ |
| `target` | | The final **converted** image path (e.g., `.jpg`, `.png`). The extension determines the format used by the underlying library. |
---
## **Workflow**
1. **Load** the **`source`** image from your storage system.
2. **Infer** the **target** format from the file extension (e.g., `.jpg`, `.png`).
3. **Apply** optional parameters like `quality` if the chosen format supports it (JPEG, etc.).
4. **Save** the image to **`target`** in the chosen format.
**Use Cases**:
- **Re-encoding** images to a standard format (e.g., always produce JPEG).
- **Specifying** a compression or quality level for JPEG/WebP outputs.
- **Simplifying** a pipeline that handles many input formats but needs a single output format.
---
## **Notes**
- This processor focuses **only on format conversion**. If you want to apply color filters or advanced transformations, use a dedicated **color_filter** or other specialized processor.
- The image’s **color mode** is generally preserved unless automatically changed by the library (e.g., saving RGBA to JPEG strips alpha). If alpha is needed, consider a format like PNG.
- If `target` is the **same** extension as `source`, this step effectively just **re-saves** the image, potentially altering compression if `quality` is different.