Assets Optimizer 📦

A powerful CLI tool that magically shrinks your app size by optimizing images. Supports recursive directory optimization with intelligent compression.

Features 🚀

  • Optimizes JPG, JPEG, and PNG files
  • Supports recursive directory scanning
  • Maintains original directory structure
  • Smart compression based on file type
  • Progress indicator with real-time feedback
  • Detailed size reduction statistics
  • Video file detection (.mp4, .mov)

Installation 📥

  1. Make sure you have Dart SDK installed. If not, install it from here.

  2. Run the following command:

dart pub global activate assets_optimizer
  1. Add the pub cache bin directory to your PATH:

    For Mac/Linux:

    # Add this to your ~/.bashrc, ~/.zshrc, or similar
    export PATH="$PATH":"$HOME/.pub-cache/bin"
    

    For Windows:

    # Add this to your PATH environment variable
    %LOCALAPPDATA%\Pub\Cache\bin
    

Project-specific Installation

Add to your pubspec.yaml:

dev_dependencies:
  assets_optimizer: ^1.0.0

Then run:

dart pub get

Usage 🛠️

If installed globally:

# Optimize all images in the assets directory
assets_optimizer custom/

# Default will work for assets/
assets_optimizer

# Get help
assets_optimizer --help

If installed in project:

# From your project root
dart run assets_optimizer optimize assets/

Compression Settings ⚙️

  • PNG files: Level 6 compression (balanced between size and quality)
  • JPG/JPEG files: 70% quality (visually lossless in most cases)

Example Output 📊

⠋ [1/5] profile.jpg 📦 1024KB → 412KB 💾 Saved: 59.8% [============>
⠙ [2/5] background.png 📦 2048KB → 890KB 💾 Saved: 56.5% [============>
...
🎉 All images processed!
📦 Total Original: 10240 KB
💾 Total Compressed: 4096 KB
🎊 Total Saved: 6144 KB

Contributing 🤝

Contributions are welcome! Please feel free to submit a Pull Request.

License 📄

MIT License - see the LICENSE file for details

Libraries

assets_optimizer