Image compression for Laravel applications
Integrate SmallPict into Laravel 10 & 11. Includes Flysystem storage adapter, Blade directives (@smallpict), model traits, and queued background optimization jobs.
Install
$ composer require smallpict/smallpict-laravelImplementation example
// In your Controller
use SmallPict\Laravel\Facades\SmallPict;
public function upload(Request $request)
{
$image = $request->file('banner');
// Automatically compresses and stores to your S3 or Cloudflare R2
$optimized = SmallPict::optimize($image)
->toFormat('webp')
->resize(1400)
->store('banners', 's3');
return response()->json(['url' => $optimized->url()]);
}
// In your Blade View
<picture>
<source srcset="@smallpict($banner->url, ['format' => 'avif'])" type="image/avif">
<source srcset="@smallpict($banner->url, ['format' => 'webp'])" type="image/webp">
<img src="@smallpict($banner->url, ['width' => 800])" alt="Banner" loading="lazy" />
</picture>Integration steps
Install via Composer
Run composer require smallpict/smallpict-laravel in your project.
Publish config
Run php artisan vendor:publish --tag=smallpict-config and set SMALLPICT_API_KEY in .env.
Use facade or Blade directive
Use SmallPict::optimize() or the @smallpict Blade directive.
Key benefits
- Artisan commands for batch media optimization (php artisan smallpict:optimize)
- Works with Spatie Media Library
- Laravel Queue support (Redis, SQS, database)
- Configurable automatic thumbnail variants
Need complete implementation guides & API specs?
Explore parameter references, authentication mechanisms, error codes, and local testing instructions in our official Laravel package developer guide.
Read Laravel package DocsSpeed Up Your Laravel package Image Pipeline
Try AVIF and WebP image optimization in your application. No setup fee, and sandbox keys right away.