> ## Documentation Index
> Fetch the complete documentation index at: https://docs.safesquid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Image analyzer

<Note>
  CLI man page: `safesquid-imgfilter(5)`
</Note>

<Frame caption="Image scoring flow">
  <img src="https://mintcdn.com/safe-squid-labs-12a0916f/VRx-_vpMam8ezhZz/images/admin_guide/image_analyzer_flowchart.svg?fit=max&auto=format&n=VRx-_vpMam8ezhZz&q=85&s=2c21a3d1c313ec324ec0928248d1a441" alt="Image scoring flow" width="480" height="160" data-path="images/admin_guide/image_analyzer_flowchart.svg" />
</Frame>

## Overview

The `Imgfilter` section (`safesquid-imgfilter(5)`) scores `image/*` response and upload bodies and blocks or debug-replaces content when the engine score is at or above a threshold. Blocked images can be replaced with a template (default `checkeredgif`).

## Core Mechanics (C++ Source Validation)

### First match wins

Walk enabled filtering policy rows top to bottom; first profile match sets threshold, bypass, debug, and template.

### MIME and size gates

Only parts whose MIME starts with `image/` are candidates. Images smaller than 50×50 pixels are skipped.

### Threshold scale

Roughly **-10** (unlikely inappropriate) through **0** (very likely). Block when engine score ≥ threshold.

### Debug mode

On responses with Debug enabled, images at or above threshold are blurred and annotated in-place; connection still marked blocked but block template not sent.

### Bypass

Bypass Image Scanning on a matching row skips buffering and scoring entirely.

## Processing flow

```mermaid theme={null}
flowchart TD
part[image/* body] --> size{>= 50x50?}
size -->|No| skip[Skip]
size -->|Yes| walk[Walk policy rows]
walk --> match{First profile match}
match --> bypass{Bypass on?}
bypass -->|Yes| skip
bypass -->|No| score[Engine score]
score --> thresh{score >= threshold?}
thresh -->|No| pass[Allow]
thresh -->|Yes| debug{Debug on response?}
debug -->|Yes| blur[Blur annotate]
debug -->|No| templ[Block template]
```

## Schema Fields

### Global fields

* **Enabled (enabled)** — Master switch; requires library init success.
* **Default template (dtempl)** — Fallback when row Template blank; default `checkeredgif`.
* **Library path (libpath)** — Path to imgfilter engine module.

### Policy rows

* **Profiles (profiles)** — Limit to tagged connections. Blank matches all.
* **Threshold (threshold)** — Block when score ≥ this value.
* **Bypass Image Scanning (bypass)** — Skip scan for matching profiles.
* **Debug (debug)** — Blur/annotate on response instead of block template.
* **Template (template)** — Replacement on block.

## Examples

### Block for students

* **Configuration:** Profiles STUDENT, Threshold 0, Template checkeredgif.
* **Result:** student image responses scoring ≥ 0 replaced with checkered template.

### Staff bypass

* **Configuration:** Row A Profiles STAFF Bypass on; Row B blank Threshold -2.
* **Result:** staff skip imgfilter; others scored via row B.

### Debug tuning

* **Configuration:** Debug on, Threshold -5.
* **Result:** borderline response images blurred with score annotation; still logged blocked.

## How to verify

1. Fetch image through profile with image-filter tag and imgfilter enabled.
2. Enable imgfilter log level for score lines.
3. Detailed logs show filter name imgfilter on block.


## Related topics

- [Image Analyzer](/use_cases/data_leakage_prevention/image_analyser_ai.md)
- [Block Inappropriate Images by Using Image Analyzer](/use_cases/data_leakage_prevention/block_inappropriate_images_by_using_image_analyzer.md)
- [Content Moderation](/use_cases/data_leakage_prevention/content_analyser.md)
- [Data Leakage Prevention](/use_cases/data_leakage_prevention/data_leakage_prevention.md)
- [Block Advertisements And Banners](/use_cases/content_modifier/block_advertisements_and_banners.md)
