MCPcopy Index your code
hub / github.com/0franco/image-auditor

github.com/0franco/image-auditor @v0.2.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.5 ↗ · + Follow
145 symbols 337 edges 19 files 16 documented · 11%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

🖼 Image Auditor

Scan your entire codebase for image performance issues. Fix them with AI. In seconds.

Image Auditor is a Rust-powered terminal tool that finds every image tag hurting your Lighthouse score, Core Web Vitals, and SEO — across all your HTML, templates, and JS frameworks — then lets your LLM fix them in one keypress.

Just run it against your repo and see exactly what's broken.


⚡ What it does

image-auditor ./my-project

Scans thousands of files in seconds, shows every broken <img> tag with severity, file, and line number — and optionally patches the code for you using OpenAI, Anthropic, or a local Ollama model.

Alt text for the image

🔎 Issues detected

Issue Impact Severity
PNG/JPG instead of WebP/AVIF Larger payload, slower LCP ⚠ Warning
Missing width / height Layout shift, high CLS score ✖ Error
Missing loading="lazy" Wasted bandwidth, slower TTI ⚠ Warning
Oversized image file (>200 KiB) Slower LCP, higher bounce rate ✖ Error
Missing srcset Serving 2× pixels on mobile ℹ Info
JSX <Image> missing alt Accessibility & SEO penalty ⚠ Warning

✨ Key features

  • Instant results — Rust scanner, handles large monorepos without breaking a sweat
  • Full TUI — keyboard-driven interface, filter by severity or issue type, search by filename
  • AI-powered fixes — press a on any issue, review the diff, apply with y
  • Safe patching — shows a before/after diff preview before touching any file
  • Multi-framework — HTML, PHP, Vue, Svelte, JSX/TSX, Handlebars, Nunjucks, EJS and more
  • JSON export — pipe results into your own reports or CI checks
  • Works offline — AI features are optional; the scanner needs nothing but the binary

📁 Supported file types

html phtml htm jsx tsx js ts vue svelte hbs ejs njk php

Auto-skips: node_modules .git dist build .next

🎬 Video Demo

demo.gif

⚡ Install & Upgrade

cargo install --path .

macOS

# Install
brew tap 0franco/ai-image-auditor
brew install image-auditor

# Upgrade
brew update
brew upgrade image-auditor

Linux (Debian / Ubuntu)

# amd64
curl -LO https://github.com/0franco/image-auditor/releases/latest/download/image-auditor_linux_amd64.deb
sudo dpkg -i image-auditor_linux_amd64.deb

# arm64
curl -LO https://github.com/0franco/image-auditor/releases/latest/download/image-auditor_linux_arm64.deb
sudo dpkg -i image-auditor_linux_arm64.deb

# Upgrade (re-run the install command for your architecture)
curl -LO https://github.com/0franco/image-auditor/releases/latest/download/image-auditor_linux_amd64.deb
sudo dpkg -i image-auditor_linux_amd64.deb

🧪 Usage

# Launch interactive TUI (menu to pick path)
image-auditor

# Scan a specific directory directly
image-auditor ./my-project
image-auditor /var/www/html

AI fixes are optional. The scanner works with no configuration. To enable them, create a .env file in the directory where you run the tool

🖥 TUI Controls

Key Action
Enter Edit path / confirm / view detail
↑ ↓ or j k Navigate
Tab / Shift+Tab Filter by issue category
1 Show all severities
2 Errors only
3 Warnings only
4 Info only
s Save report to image-audit-report.json
c Copy current row file path to clipboard
q / Esc Back / quit
a (Detail view) Ask AI for an automatic code fix suggestion
p (Detail view) Preview & apply the AI‑proposed patch (with confirmation)

🤖 AI-powered fixes

Press a on any issue and your configured LLM (OpenAI, Anthropic, or local Ollama) will read the exact file context, diagnose the problem, and propose a minimal code patch — touching only the attributes that are actually missing.

Issue: Missing height attribute — causes layout shift (CLS)

  Before  │  <img src="https://github.com/0franco/image-auditor/raw/v0.2.5/assets/img/hero.png" alt="Hero" width="1280">
  After   │  <img src="https://github.com/0franco/image-auditor/raw/v0.2.5/assets/img/hero.png" alt="Hero" width="1280" height="640">

The workflow is non-destructive by design:

  1. a — ask the LLM (confirmation prompt guards against accidental token spend)
  2. p — review the full before/after diff before anything is written
  3. y — apply, or n / Esc to cancel
  4. The file is patched in-place and the scan reruns automatically — fixed issues disappear from the list immediately

Supported providers — set ACTIVE_LLM_PROVIDER in your .env:

Provider Variable Default model
OpenAI OPENAI_API_KEY gpt-5.2
Anthropic ANTHROPIC_API_KEY claude-sonnet-4-6
Ollama (local) qwen3-coder:30b

Skip the confirmation prompt when iterating quickly:

LLM_SKIP_CONFIRM=1

Enable verbose mode to get a full explanation alongside the patch:

AI_VERBOSE=1

🔧 Configuring the AI engine

The AI helper is fully optional and controlled through environment variables. Use the provided .env.example as a starting point:

cp .env.example .env

Then edit .env and pick your provider:

# Possible values: openai, anthropic, ollama
ACTIVE_LLM_PROVIDER=openai
OPENAI_API_KEY=sk-...

# Optional: skip confirmation prompt in the TUI
LLM_SKIP_CONFIRM=true

OpenAI

OPENAI_API_KEY=your-openai-api-key
# Optional:
# OPENAI_BASE_URL=https://api.openai.com
# OPENAI_MODEL=gpt-5.2

Anthropic

ANTHROPIC_API_KEY=your-anthropic-api-key
# Optional:
# ANTHROPIC_BASE_URL=https://api.anthropic.com
# ANTHROPIC_MODEL=claude-sonnet-4-6

Ollama (local)

ACTIVE_LLM_PROVIDER=ollama
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=qwen3-coder:30b

Once your environment is set, launch image-auditor, open an issue detail, and hit a to let the AI propose a fix — then py to apply it in seconds.

🏗 Build

cargo build --release
./target/release/image-auditor

🤝 Contributing

Contribute! Please open an issue or submit a pull request.

Buy Me A Coffee

Extension points exported contracts — how you extend this code

LlmClient (Interface)
(no doc) [3 implementers]
src/llm.rs

Core symbols most depended-on inside this repo

path
called by 17
src/scanner/checks.rs
update_filter_cache
called by 14
src/app.rs
check_wrong_format
called by 6
src/scanner/checks.rs
check_missing_dimensions
called by 6
src/scanner/checks.rs
filtered_issues
called by 5
src/app.rs
get_attr
called by 5
src/scanner/attrs.rs
has_attr
called by 5
src/scanner/attrs.rs
check_missing_lazy
called by 5
src/scanner/checks.rs

Shape

Function 113
Class 18
Method 9
Enum 4
Interface 1

Languages

Rust100%

Modules by API surface

src/scanner/checks.rs23 symbols
src/llm.rs22 symbols
src/scanner/mod.rs17 symbols
src/scanner/attrs.rs15 symbols
src/app.rs15 symbols
src/tui/input.rs11 symbols
src/tui/render/detail.rs9 symbols
src/tui/mod.rs6 symbols
src/tui/actions.rs5 symbols
src/scanner/types.rs5 symbols
src/tui/render/widgets.rs4 symbols
src/patch.rs4 symbols

For agents

$ claude mcp add image-auditor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page