# Image Write

This function block is designed to save an input image to a specified folder with a defined filename, contingent upon an active condition. It offers options for file formats and compression.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Folder Path` The path to the folder where the image will be saved.

`File Name` The name to be used for the saved image file.

`Write Condition` A boolean value that, when true, triggers the saving of the image.

`Input Image` The image data that will be saved.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

This function block does not produce any outputs.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Compress Image?` A checkbox that allows users to choose whether to compress the saved image (if selected, the image will be saved as a JPEG with specified quality).

## 🎨 Features <a href="#features" id="features"></a>

`File Format Options` Supports saving images in both PNG and JPEG formats based on user preference.

`Dynamic Path and Filename` Users can specify the folder path and filename dynamically at runtime, using either a specific filename or a timestamp in the absence of one.

`Compression Control` The ability to enable or disable image compression allows for greater flexibility in image quality management.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. **Specify Folder Path**: Enter the desired path for the folder where you wish to save the image.
2. **Define File Name**: Input a name for your image file. If not provided, a timestamp will be used.
3. **Set Write Condition**: Ensure the `Write Condition` input is set to `True` to enable saving of the image when conditions are met.
4. **Connect Input Image**: Link the image data you wish to save to the `Input Image` input.
5. **Evaluate**: Run the block, and if the Write Condition is true, the image will be saved at the specified location.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

Upon evaluation, if the Write Condition is met and the image data is valid, the function block will save the image to the specified folder with the chosen filename and format.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

<details>

<summary>Using Timestamps for Filenames</summary>

If you want to save images at different times without overwriting, enter nothing in `File Name` input. The function will use a timestamp to create a unique filename each time an image is saved.

</details>

<details>

<summary>Ensure Folder Exists</summary>

Before running the block, ensure that your specified folder path exists. If it doesn’t, the saving operation may fail.

</details>

<details>

<summary>Compressing Images</summary>

When saving images as JPEG, enabling the `Compress Image?` option will reduce file size but may affect quality. Adjust the quality parameter as necessary to balance size and quality.

</details>

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

<details>

<summary>No Image Data Available</summary>

Ensure that the `Input Image` is connected and containing valid image data. You can use the debugging feature from other blocks to verify the data flowing through.

</details>

<details>

<summary>File Path Issues</summary>

If you receive an error regarding the file path, check that the specified folder path is correct. Ensure that all directories in the given path exist before running this block.

</details>
