Description
This package can optimize PNGs, JPGs, WEBPs, AVIFs, SVGs and GIFs by running them through a chain of various image optimization tools. Here's how you can use it:
use Spatie\ImageOptimizer\OptimizerChainFactory;
$optimizerChain = OptimizerChainFactory::create();
$optimizerChain->optimize($pathToImage);
The image at $pathToImage will be overwritten by an optimized version which should be smaller. The package will automatically detect which optimization binaries are installed on your system and use them.
Recent Courses on Laravel Daily
AI Agents/IDEs for Laravel: May 2026 (Claude Code, Codex, OpenCode, etc)
7 lessons
52 min
How to Structure Laravel 13 Projects
16 lessons
1 h 32 min read
[FREE] Laravel 13 for Beginners: 3 Demo Projects
5 lessons
29 min