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 π₯
Global Installation (Recommended)
-
Make sure you have Dart SDK installed. If not, install it from here.
-
Run the following command:
dart pub global activate assets_optimizer
-
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