Files
watermark-wizard/spec/prd.md
Julian Freeman 8a92eea397 phase 1 & 2 first
2026-01-18 22:55:12 -04:00

4.9 KiB

PRD: WatermarkWizard - AI-Powered Intelligent Image Processor


1. Project Vision

WatermarkWizard is a high-performance desktop application built with Tauri + Vue3. It solves the problem of "watermark collision" by using smart algorithms to place new watermarks in non-obstructed areas. It also leverages local AI Inpainting to remove existing text-based watermarks.


2. Technical Stack & Constraints

  • Frontend: Vue 3 (Composition API), Vite, Pinia, TypeScript, Tailwind CSS.
  • Backend: Rust (Tauri 2.0), image crate, rayon (Parallelism), ort (ONNX Runtime).
  • Package Manager: pnpm.
  • Target OS: Windows, macOS (Universal execution, local-first).

3. Key Technical Solutions

3.1 High-Performance Local Image Preview

To display local images without the overhead of Base64 encoding, the system utilizes the Tauri Asset Protocol.

Security Configuration (tauri.conf.json):

{
  "tauri": {
    "security": {
      "csp": "default-src 'self'; img-src 'self' asset: [https://asset.localhost](https://asset.localhost)",
      "assetProtocol": {
        "enable": true,
        "scope": ["**"] 
      }
    }
  }
}

Frontend Implementation: Using @tauri-apps/api/core, we convert absolute system paths into browser-safe URLs:

import { convertFileSrc } from '@tauri-apps/api/core';
const previewUrl = convertFileSrc('/path/to/image.jpg');

3.2 Smart Placement: "Zone Complexity Analysis" (ZCA)

To avoid overlapping existing logos or AI software watermarks, the system implements a Standard Deviation of Luma algorithm.

The Algorithm Logic:

  1. Segmentation: Divide the bottom 20% of the image into three zones: Left, Center, and Right.

  2. Luma Calculation: Convert pixels to grayscale () using:

  3. Variance Assessment: Calculate the Standard Deviation () for each zone:

  4. Decision: The zone with the **lowest ** (the most uniform area) is selected as the optimal anchor.


4. User Interface & Interaction Design

4.1 "Hero-Strip" Layout

Designed for professional workflows, mimicking high-end photo editing software.

A. Hero View (Main Editor)

  • Large Dynamic Preview: Displays the currently selected image with a CSS-based watermark overlay.
  • Real-time Interaction: Users can drag the watermark within the Hero View. The position is stored as a Percentage Coordinate () to ensure resolution independence during export.
  • Quick Switch: Lateral floating buttons and arrow key support for rapid navigation.
  • Horizontal Virtual List: Powered by vue-virtual-scroller to handle 5,000+ images at 60fps.
  • Lazy Loading: High-res images are only fetched for the Hero View; the gallery uses lightweight cached thumbnails generated by the Rust backend.

5. Functional Requirements

5.1 Intelligent Batch Watermarking

  • Requirement: Apply a consistent watermark across diverse image sets without manual positioning for every file.
  • Smart Logic: Default to the ZCA-calculated position. If the user manually moves a watermark on one image, provide a "Sync to All" option to override the algorithm for the entire batch.

5.2 AI-Powered Watermark Removal

  • Requirement: Eliminate existing text watermarks without "blurring" artifacts.
  • Logic:
  1. Text Detection: OCR (via ONNX) generates bounding boxes for characters.
  2. Local Inpainting: The LaMa (Large Mask Inpainting) model brain-fills the background textures based on surrounding context.
  • Manual Refinement: A brush tool in the Hero View allows users to "paint" over stubborn artifacts for re-processing.

6. Performance & Security Optimization

  • Parallel Processing: Image compositing is handled by rayon, distributing tasks across all available CPU threads.
  • Zero-Cloud Policy: All AI models (OCR and Inpainting) run locally via ort (ONNX Runtime), ensuring user privacy and offline capability.
  • Thumbnail Pre-gen: Upon folder selection, Rust triggers a background thread to generate 300px thumbnails in the system's temp directory.

7. API & Command Architecture (Rust)

Command Payload Description
scan_dir path: String Recursively scans folder and generates initial metadata/thumbnails.
get_zca_suggestion path: String Performs Zone Complexity Analysis on a specific file.
run_inpainting img: Path, mask: Mask Executes the LaMa ONNX model on a masked region.
export_batch tasks: Vec<Task> High-speed parallel export using Rust image crate.

8. Development Roadmap

  1. Phase 1: Core architecture setup (Tauri + Asset Protocol + Pinia Store).
  2. Phase 2: Implementation of ZCA Algorithm in Rust and the Hero-Strip UI.
  3. Phase 3: Integration of ONNX Runtime for LaMa Inpainting.
  4. Phase 4: Parallel batch export and performance profiling.