asset_opt 1.0.1 asset_opt: ^1.0.1 copied to clipboard
A Flutter/Dart tool for analyzing and optimizing project assets. Provides detailed analysis, recommendations, and automatic optimizations for images.
asset_opt π― #
A powerful Flutter/Dart tool for analyzing and optimizing project assets. Get detailed insights into your asset usage and automatically optimize images to improve your app's performance.
Features π #
Detailed Asset Analysis #
- π Size and type distribution visualization
- π Directory structure breakdown
- π Image dimension analysis
- β οΈ Issue detection and recommendations
Smart Optimization #
- ποΈ Automatic image compression
- π Size reduction while maintaining quality
- π Format conversion suggestions
- πΎ Safe backups before optimization
Beautiful Reports #
- π Visual progress tracking
- π¨ Color-coded terminal output
- π Detailed JSON reports
- π Size statistics and savings
Installation π₯ #
dart pub global activate asset_opt
Or add to your pubspec.yaml
for project-specific usage:
dev_dependencies:
asset_opt: ^1.0.1
Usage π» #
Command Line #
# Show help and available commands
asset_opt --help
# Analyze project assets
asset_opt --analyze
# Analyze and optimize
asset_opt --optimize
# Specify project path and quality
asset_opt -p /path/to/project -q 85 --optimize
# Verbose output
asset_opt --verbose
As a Library #
import 'package:asset_opt/asset_opt.dart';
void main() async {
// Initialize services
final fileService = FileService();
final imageService = ImageService();
final analysisState = AnalysisState();
// Create analyzer
final analyzer = AnalyzeCommand(
fileService,
imageService,
analysisState,
);
// Run analysis
final analysis = await analyzer.execute('./');
// Check for issues
if (analysis.hasIssues()) {
print('Found optimization opportunities:');
for (final asset in analysis.assets) {
if (asset.issues.isNotEmpty) {
print('${asset.info.name}:');
for (final issue in asset.issues) {
print(' - ${issue.message}');
}
}
}
}
}
Output Examples πΈ #
Asset Analysis #
π Asset Analysis Report
ββββββββββββββββββββββββ
Project: /Users/username/projects/my_app
ββββββββββββββββββββββββ
ββ assets (632 files, 22.4 MB)
ββ images (631 files, 22.4 MB)
β ββ flags (492 files, 3.7 MB)
β ββ bgs (4 files, 2.5 MB)
ββ icons (1 files, 829 B)
Type Distribution #
π Assets by Type
ββββββββββββββββββββββββ
Type Size Files Distribution
PNG 22.4 MB 631 βββββββββββββββββββββββββββββ β 65.2%
JPEG 10.2 MB 492 βββββββββββββββββ β 29.8%
WEBP 1.5 MB 4 ββββ β 4.3%
SVG 829.0 B 1 β β 0.7%
Optimization Suggestions #
β οΈ Optimization Opportunities
ββββββββββββββββββββββββ
β background.png
Current: 2.5 MB
Recommended: < 500 KB (reduce by 80%)
β Use pngquant or tinypng for lossless compression
Configuration βοΈ #
Create asset_opt.yaml
in your project root:
# Asset optimization settings
optimization:
jpeg_quality: 85
webp_quality: 80
strip_metadata: true
# Size limits
limits:
max_file_size: 1MB
max_total_size: 50MB
# Patterns to exclude
exclude:
- '**/test/assets/*'
FAQ β #
Q: Is it safe to use on production assets? A: Yes! The tool creates backups before any optimization.
Q: What image formats are supported? A: Currently supports PNG, JPEG, WebP, and SVG files.
Q: Will this work with my CI/CD pipeline? A: Yes, the tool can be integrated into CI/CD workflows.
Contributing π€ #
Contributions are welcome! Please read our contributing guidelines before submitting pull requests.
Roadmap πΊοΈ #
Version 1.2.0 #
- β Configuration file support
- β Custom optimization presets
- β Watch mode for development
Version 1.3.0 #
- β WebP conversion
- β SVG optimization
- β Asset usage analysis
License π #
Licensed under the MIT License file for details.
Support πͺ #
If you find this tool helpful, please consider:
- Starring the repository β
- Reporting issues π
- Contributing to the code π»
- Sharing with others π