Skip to content
smallPict
Start free
HomeIntegrationsLaravel package

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

PHP Package
$ composer require smallpict/smallpict-laravel

Implementation example

php
// 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

  1. Install via Composer

    Run composer require smallpict/smallpict-laravel in your project.

  2. Publish config

    Run php artisan vendor:publish --tag=smallpict-config and set SMALLPICT_API_KEY in .env.

  3. 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 Docs

Speed Up Your Laravel package Image Pipeline

Try AVIF and WebP image optimization in your application. No setup fee, and sandbox keys right away.