How garthtb/lightness-curve works
Project Type and Purpose
• This is a standalone, cross-platform CLI image-analysis tool written in Rust.
• It ingests a directory (potentially ZIP archives) of images, computes per-frame brightness metrics (RGB avg, luminance, HSV channels, ROI), and emits CSV and/or SVG outputs.
• It is zero-dependency (static binary), high-throughput (parallel processing), config-driven, and automatable (no UI).
File Structure Analysis
• Top-level:
• Cargo.toml / Cargo.lock: Rust package manifest & lock file
• config/config.toml: default example configuration
• src/: source code broken into modules
• src/:
• main.rs – application entry: parse config, orchestrate pipeline
• config.rs – loads and validates config settings
• core.rs – pipeline control logic: file enumeration, parallel dispatch
• output_generator.rs – CSV writer and SVG-plot renderer
• This separation suggests a modular pipeline architecture:
Config loader → Core orchestrator → Image processing utilities → Output generator
Key Insights from README
• Parallel processing for performance
• Supports multiple image formats and metrics
• Driven entirely by config.toml
• Outputs CSV and SVG
• No interactive UI; pure CLI
Components
a. Configuration
– Component: “Config Loader”
– Input: config/config.toml or user-provided config.toml
b. Orchestration
– Component: “Core Pipeline”
– Responsibilities: scan directory, sort images, manage parallel tasks
c. Image Processing
– Component: “Image Utils Module”
– Responsibilities: decode image (JPEG, PNG, BMP, TIFF, WebP), extract ROI, compute metrics (RGB avg, Luminance, H/S/V)
d. Output Generation
– Component: “Output Generator”
– Responsibilities: aggregate results, write CSV, generate SVG line plot
e. External Interfaces
– File system (input images, output files)
– ZIP decompression (if applicable)
– Rust standard library and crates (e.g., image, rayon)
f. Execution Environment
– Single binary runs on host OS
Architectural Patterns & Principles
• Pipeline/Stage processing: clear stages from config to output
• Modularity: each src/*.rs is a self-contained module
• Parallelism: use of Rayon (or similar) to process images concurrently
• Single responsibility: strict separation of config, core logic, utilities, and output
• Zero runtime dependencies: static linking and minimal external crates