Crate pixie_anim_lib

Crate pixie_anim_lib 

Source
Expand description

§Pixie-Anim

A zero-dependency, SIMD-accelerated GIF optimizer.

§Pixie-Anim

Pixie-Anim Logo

Crates.io Docs.rs Build Status License

Pixie-Anim Architecture

A high-performance, zero-dependency short-form animation optimizer written in Rust and WebAssembly.

Inspired by Lee Robinson’s pixo, Pixie-Anim follows a similar philosophy: building mission-critical codecs from scratch without heavy runtime dependencies, optimized for both native CLI performance and zero-latency in-browser execution.

§🚀 Key Features

  • Zero-Dependency Core: From-scratch implementation of GIF89a and LZW.
  • Superior Compression: Achieves 30-50% smaller files than Gifsicle -O3 through advanced heuristics.
  • Perceptual Quantization: Uses CIELAB color space and K-Means++ for superior color fidelity.
  • Temporal Denoising: Index-reuse logic that treats temporal noise as negligible, dramatically reducing size for real-world video.
  • Stable Dithering: Choice of Ordered (Bayer) or Blue Noise dithering to eliminate spatial “shimmer.”
  • Evaluation-Driven Presets: Smart High/Medium/Low presets determined through thousands of iterations of Gemini-based perceptual scoring.
  • Parallelized & SIMD: Multi-threaded quantization via Rayon and Planar AVX2/NEON kernels for nearest-color search.
  • WASM Playground: Fully functional, client-side optimizer with direct MP4-to-GIF support.
  • Subjective LLM Judge: Automated quality evaluation via Gemini 3 Flash.

§📊 Performance Matrix (Space Waves - 720p)

ToolModeSize (KB)Subjective Score (1-10)
Gifsicle -O3Standard19,0346
FFmpeg2-Pass HQ19,2906
Pixie-AnimQuality/Lossy9,8217

Benchmarked on the high-complexity “Space Waves” sequence (Veo 3.1). Pixie-Anim provides a massive size advantage while improving visual stability through Ordered Dithering.

§🧠 Algorithms

§Zeng Palette Reordering

By ordering the 256-color palette by visual similarity, we maximize the length of LZW strings, gaining “free” compression with negligible compute cost.

§Lossy LZW (Fuzzy Neighbor Matching)

A unique optimization where the encoder can match visually similar “neighbor” indices in the Zeng-ordered palette to continue an LZW sequence, further collapsing file size.

We discovered that standard interleaved RGB SIMD is often slower than scalar for small palettes. Pixie-Anim uses a Planar data layout to unlock the true potential of AVX2/NEON for nearest-color search.

§🛠 Usage

§CLI

Build the native binary:

cargo build --release --features="cli"

The binary will be available at target/release/pixie-anim.

Optimize an image sequence:

./target/release/pixie-anim frames/*.png --output optimized.gif --fps 15 --lossy 8 --fuzz 10

§Web Playground

The web UI is a Lit-based application that leverages the Rust core via WASM.

  1. cd web
  2. pnpm install
  3. pnpm run dev (This automatically triggers build-wasm to generate bindings)
  4. Drop an MP4 or GIF into the browser and select an Optimization Preset (Low, Medium, High).
  5. Pixie-Anim will process the file locally in your browser.

Note: To prevent browser memory exhaustion, the web playground currently scales video to 640px and caps extraction at 300 frames. Use the CLI for unlimited high-resolution processing.

§📊 Benchmarking & Evaluation

Pixie-Anim includes a unified benchmarking tool to compare performance and visual quality against Gifsicle, FFmpeg, and gifski.

See tests/README.md for detailed instructions on the Hill-Climbing workflow and iterative performance tuning.

Quick Benchmark:

./target/release/pixie-bench --input video.mp4 --name my_test --lossy 8 --report tests/benchmarks.md

This tool automatically:

  1. Extracts frames via ffmpeg.
  2. Runs the optimization suite across all four engines.
  3. Invokes the Gemini Subjective Judge for quality scoring.
  4. Generates a detailed Markdown report with size, speed, and visual critique.

Image

§👁️ Automated Evaluation

Pixie-Anim includes a judge tool that uses Gemini 3 Flash to perform a comparative analysis of the output, identifying artifacts like banding or temporal jitter that traditional metrics (PSNR/SSIM) might miss.

§📋 Prerequisites

§Core Development

  • Rust (1.70+)
  • Node.js & npm/pnpm (For Web Playground)
  • wasm-bindgen-cli (cargo install wasm-bindgen-cli)

§Benchmarking & Evaluation

To run the comparative benchmarks and the subjective judge, you’ll need:

  • FFmpeg: For frame extraction and judge frame analysis.
  • Gifsicle: For baseline compression comparison.
  • gifski: For high-quality comparison.
  • bc: For benchmark timing calculations.
  • Gemini API Key: Set as GEMINI_API_KEY in your environment or .env file for the judge tool.

Install on macOS via Homebrew:

brew install ffmpeg gifsicle gifski bc

Part of the Pixie family of high-performance media tools

Re-exports§

pub use error::Error;
pub use error::Result;

Modules§

bits
Bit-level reading and writing utilities. Bit-level reading and writing utilities.
color
Color space conversions and perceptual distance. Color space conversions and perceptual distance.
delta
Inter-frame Delta Compression. Inter-frame Delta Compression.
error
Error handling. Error handling.
gif
GIF89a Structure and Writing. GIF89a Structure and Writing.
lzw
LZW Encoder for GIF89a.
quant
Quantization algorithms for GIF.
simd
SIMD acceleration module for performance-critical operations.