# Image Logger

This function block saves incoming image frames to disk with configurable file naming, format and storage limits. Use it to capture and archive images when a trigger signal is received, or to periodically dump images for inspection.

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

`Folder Path` - Destination folder where images will be saved. Provide a valid path.

`File Name` - Optional file name. If empty, a timestamp-based name will be used.

`Image Limit` - Optional maximum number of images to keep in the folder. When the limit is exceeded, the oldest images are removed.

`Input Image` - Image data to be saved. Connect any image-producing block to this input.

`Trigger` - Boolean trigger that controls saving. When the trigger condition is active, the image will be written according to the configured settings.

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

This function block does not produce any outputs.

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

`Save Mode` - Dropdown control to choose between `Full Size` (PNG) and `Compressed` (JPEG) saving modes. Compressed mode reduces file size at the cost of quality.

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

* Automatic timestamp naming when `File Name` is not provided.
* Optional image compression to reduce disk usage.
* Folder image count limit with automatic deletion of oldest files to enforce the limit.
* Works with any incoming image source (cameras, loaders, or processed images).
* Clear error and info messages are logged when saving succeeds or fails.

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

1. Set the destination by providing `Folder Path` or use a block that supplies it.
2. Optionally provide a `File Name`; leave empty to use an automatic timestamp name.
3. Optionally set `Image Limit` to control how many images are kept in the folder.
4. Connect an image source to `Input Image`.
5. Use `Trigger` to control when images are written. Toggle the trigger to save the current image.
6. Choose the desired `Save Mode` for PNG or compressed JPEG output.

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

When the block receives a valid `Input Image` and the `Trigger` condition is satisfied, it attempts to save the image to the provided `Folder Path` using the chosen `Save Mode`. If the folder contains more images than `Image Limit`, the oldest files are removed to respect the limit. Informational messages indicate success; error messages explain failures (invalid path, write permissions, etc.).

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

* Use `Choose Folder` to let users visually pick the target folder and feed it into `Folder Path`.
* Use `Date-Time` (timestamp) together with `File Name` to create human-readable names for chronological sorting.
* Preview images before saving by sending the same image to `Show Image` so you can inspect frames visually.
* Reduce disk usage by adding an `Image Resizer` before this block to downscale very large images prior to saving.
* When capturing from live sources, combine with `Camera USB`, `Camera IP (ONVIF)`, or `Stream Reader` as the image provider to archive frames from cameras or streams.
* If you need structured metadata alongside files, send detection/measurement outputs to `CSV Export` to log details (file name, timestamp, counts).
* Use `File/Folder Operations` to create folders or manage saved files programmatically before or after logging.
* For application flows that write multiple images at once, consider `Multi Image Write` or `Image Write` blocks as alternatives when you need different naming or trigger behaviour.

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

* Invalid folder errors: check that `Folder Path` exists and the application has write permissions. Use `File/Folder Operations` to create required folders first.
* No image saved: verify that `Input Image` is connected and that `Trigger` is active when you expect a save.
* Images accumulate too many files: set a reasonable `Image Limit` or run a cleanup routine using `File/Folder Operations`.
* Large files slow down saving: switch `Save Mode` to `Compressed` or add an `Image Resizer` upstream.
* If filenames collide, include a timestamp (via `Date-Time`) or an index to ensure unique names.


---

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