# Image Write

This function block saves input images to disk when a save condition is active. It supports optional compression (JPEG) and automatic naming, and is intended for easy export of captured or processed images.

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

`Folder Path`\
Full folder path where the image will be saved. If left empty, the current working folder is used.

`File Name`\
Optional file name without extension. If left empty, a timestamp-based name is used automatically.

`Save`\
Boolean trigger that controls whether the image will be written to disk. Provide TRUE to save, FALSE to inhibit saving.

`Input Image`\
Image to be saved. Accepts any common image format coming from previous blocks.

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

This function block does not produce output sockets. It reports status through log messages visible in the UI.

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

`Compress Image`\
Checkbox to toggle saving as a compressed JPEG file instead of an uncompressed PNG. Use compression to reduce file size when disk space or transfer bandwidth is a concern.

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

* Save on-demand using a boolean `Save` input.
* Automatic filename fallback using a timestamp when no name is given.
* Option to save as compressed JPEG or lossless PNG.
* Informative log messages confirming success or reporting errors (missing folder, permission, or missing image).
* Simple UI control for enabling/disabling compression.

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

When the `Save` input is active (TRUE), the block attempts to write the current `Input Image` to the path defined by `Folder Path` and `File Name`. If `Compress Image` is checked, the image is saved as JPEG to reduce size; otherwise it is saved as PNG. If the folder does not exist or the image is missing, the block logs an error instead of saving.

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

1. Provide a destination using the `Folder Path` input or leave it empty to use the default folder.
2. Optionally set a `File Name` or leave empty to use an automatic timestamped name.
3. Feed the image you want to save into the `Input Image` socket.
4. Activate the `Save` input (for example with a manual or programmatic trigger) to write the file.
5. Use the `Compress Image` checkbox to choose between JPEG (smaller) or PNG (lossless).

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

* Use `Choose Folder` to let users pick the target folder interactively before saving.
* Combine with `String Input` or `Date-Time` to build descriptive, timestamped file names.
* Preview the image with `Show Image` before saving to verify content.
* If images are large, add `Image Resizer` before this block to reduce saved file size and improve throughput.
* Use `Image ROI Select` or `Draw Result On Image` to crop or annotate images prior to saving (for examples: saving detected regions or overlayed results).
* For high-rate logging of many images, consider using `Image Logger` or `Record Video` instead of saving individual frames on every trigger.

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

* Folder not existing or write permission error: verify the path provided by `Folder Path` and use `Choose Folder` to avoid typos.
* "No image data available" error: ensure the `Input Image` socket is receiving valid image data before sending the `Save` trigger. Preview with `Show Image` to confirm.
* Large files or slow saves: enable `Compress Image` or insert `Image Resizer` to reduce resolution before saving.
* Unexpected filenames: include `Date-Time` or a custom `String Input` to generate unique, descriptive names and avoid overwriting.

If saving repeatedly in short intervals, ensure the destination storage has sufficient free space and write performance for your scenario.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/input-output/outputs-exports/image-write.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
