Skip to main content
Back to packages
2,876 GitHub stars

spatie/image-optimizer

View on GitHub

Description

Optimize PNGs, JPGs, SVGs and GIFs by running them through a chain of various image optimization tools

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

Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks

7 lessons
43 min read

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

Laravel 13 Eloquent: Expert Level

41 lessons
1 h 34 min