Skip to content

A photo optimizer package for AI coding agents to easily optimize images to AVIF and WebP for web and mobile applications.

Notifications You must be signed in to change notification settings

SourceCode/aitools-photo-optimizer

Repository files navigation

Aitools Photo Optimizer

Adaptive, AI-Ready Image Optimization for the Modern Web.

License Coverage Build Status

Project Overview

aitools-photo-optimizer is a high-performance, strictly typed monorepo designed to automate image optimization workflows. It analyzes source images, intelligently classifies them (Photo vs Icon vs Screenshot), and generates optimized multi-format variants (AVIF, WebP) tailored to the content type.

Key Capabilities:

  • Smart Classification: Uses heuristics to determine if an image is a photo or graphic/icon.
  • Adaptive Encoding: applies different compression settings based on classification (e.g., lossy for photos, lossless for icons).
  • Source Updating: Automatically rewrites HTML/JS/TS source files to reference generated assets.
  • Monorepo Architecture: Modular design separating Core logic, Node.js CLI/Runtime, and Web Runtime.
  • Agent-Ready: Designed with strict typing and clear boundaries, making it ideal for AI agent integration.

Architecture Summary

The project is structured as a pnpm workspace with the following packages:

  • @aitools-photo-optimizer/core: Pure logic, domain models, hashing, and planning. No side effects.
  • @aitools-photo-optimizer/node: Node.js runtime, CLI, Worker Pool, file system IO, and Sharp integration.
  • @aitools-photo-optimizer/web: Browser runtime for dynamic asset loading and observation.
  • apps/demo: A Vite-based demo application showcasing the web runtime.

See Implementation Docs for a deep dive.

Tech Stack

  • Runtime: Node.js >= 24.0.0, Modern Browsers
  • Languages: TypeScript 5.x
  • Build System: Turbo / pnpm workspaces / Vite / tsup
  • Testing: Vitest, native node test runner
  • Image Processing: sharp (libvips)
  • Code Quality: ESLint, Prettier, Husky

Quick Start

Prerequisites

  • Node.js 24+
  • pnpm 9+

Running Locally

# 1. Install dependencies
pnpm install

# 2. Build detailed packages
pnpm build

# 3. Run the demo app
pnpm -C apps/demo dev

For full details, see Installation and First Run.

Configuration

Configuration is handled via CLI flags and standard node conventions. See Setup Guide for environment variables and advanced config.

Testing & Coverage

We maintain high test coverage (>90%).

# Run all tests
pnpm test

# Run with coverage (results in coverage/)
pnpm run test --coverage

See Coverage Report.

Documentation Index

Contributing

We welcome contributions! Please check Contributing for guidelines on PRs, commit messages, and code style.

License

MIT

About

A photo optimizer package for AI coding agents to easily optimize images to AVIF and WebP for web and mobile applications.

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published