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