PHPackages                             emiliolodigiani/laravel-images - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. emiliolodigiani/laravel-images

ActiveLibrary[Image &amp; Media](/categories/media)

emiliolodigiani/laravel-images
==============================

Responsive image resizing with srcset generation for Laravel

v1.4.2(3mo ago)0769↓91.7%MITPHPPHP ^8.3

Since Mar 22Pushed 3mo agoCompare

[ Source](https://github.com/emiliolodigiani/laravel-images)[ Packagist](https://packagist.org/packages/emiliolodigiani/laravel-images)[ RSS](/packages/emiliolodigiani-laravel-images/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (4)Versions (11)Used By (0)

Laravel Images
==============

[](#laravel-images)

Responsive image resizing with srcset generation for Laravel.

Automatically resizes images to multiple WebP variants and generates `` tags with `srcset` for optimal loading. Configurable image sources allow each project to define its own directories and URL structure.

Installation
------------

[](#installation)

```
composer require emiliolodigiani/laravel-images
```

Publish the config file:

```
php artisan vendor:publish --tag=images-config
```

Configuration
-------------

[](#configuration)

Define your image sources in `config/images.php`:

```
return [
    'quality' => 80,
    'widths' => [400, 800, 1200, 1920, 2500],
    'sources' => [
        'default' => [
            'originals'     => public_path('images'),
            'originals_url' => '/images',
            'sizes'         => public_path('images/sizes'),
            'url'           => '/images/sizes/{width}',
        ],
        // Add more sources as needed:
        'blog' => [
            'originals'     => storage_path('app/public/blog'),
            'originals_url' => '/storage/blog',
            'sizes'         => storage_path('app/public/blog-sizes'),
            'url'           => '/storage/blog-sizes/{width}',
        ],
    ],
];
```

Each source defines:

- **originals** — absolute path to the directory with original images
- **originals\_url** — public URL prefix for originals (used as fallback when no resized versions exist)
- **sizes** — absolute path where resized versions are stored (subdirectories per width)
- **url** — public URL pattern for srcset (`{width}` is replaced with the actual value)

Usage
-----

[](#usage)

### Blade component

[](#blade-component)

```

```

The component outputs an `` tag with `srcset` and `sizes` attributes. If no resized versions exist, it falls back to the original.

### HTML body helper

[](#html-body-helper)

For rich text content with embedded `` tags:

```
{!! responsive_images($model->body) !!}
```

This transforms all `` tags in the HTML to responsive versions with `srcset`, `sizes`, and `loading="lazy"`.

### Resize after upload

[](#resize-after-upload)

The package does not handle file storage — your app saves files using Laravel's filesystem (Storage, Livewire `storeAs()`, controller `store()`, etc.). After saving, call `ImageResizer::resize()` with the absolute path to generate all resized versions.

The `resize()` method automatically detects which configured source the file belongs to based on its path.

```
use EmilioLodigiani\LaravelImages\ImageResizer;

// Livewire component
$this->photo->storeAs('', $filename, 'my-disk');
ImageResizer::resize(storage_path('app/public/photos/' . $filename));

// Controller
$request->file('image')->store('photos', 'public');
ImageResizer::resize(storage_path('app/public/photos/' . $filename));

// Downloaded from URL (e.g. MCP tool)
file_put_contents($path, Http::get($url)->body());
ImageResizer::resize($path);
```

### Deleting images

[](#deleting-images)

Use `ImageResizer::delete()` to remove an image and all its resized versions:

```
ImageResizer::delete('photo.jpg', 'default');
```

### Batch resize

[](#batch-resize)

Generate missing resized versions for all configured sources:

```
php artisan images:resize
```

### Programmatic access

[](#programmatic-access)

```
use EmilioLodigiani\LaravelImages\ImageResizer;

// Get available widths for an image
$widths = ImageResizer::availableWidths('photo', 'default'); // [400, 800, 1200, 1920]

// Get the public URL for a specific size
$url = ImageResizer::url('photo', 800, 'default'); // /images/sizes/800/photo.webp
```

How it works
------------

[](#how-it-works)

1. When an image is resized, WebP versions are generated for each configured width that is smaller than the original
2. Images are scaled by their **longer side** (portrait images scale by height, not width)
3. A PHP manifest file at `storage/framework/image-sizes.php` tracks which sizes exist for fast lookup (no database queries)
4. The manifest is automatically updated after each resize operation and OPcache-invalidated for zero-downtime deploys

Customizing the view
--------------------

[](#customizing-the-view)

Publish the Blade view to customize the `` output:

```
php artisan vendor:publish --tag=images-views
```

The view will be at `resources/views/vendor/laravel-images/components/img.blade.php`.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12
- Intervention Image 3 (GD driver)

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance82

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

10

Last Release

94d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.4.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/e79bdb9d506f93beebc285084e6d4fd30dd4cc2577b6fd7e266dafd55c68bed7?d=identicon)[emilio.lodigiani](/maintainers/emilio.lodigiani)

---

Top Contributors

[![emiliolodigiani](https://avatars.githubusercontent.com/u/6483460?v=4)](https://github.com/emiliolodigiani "emiliolodigiani (11 commits)")

---

Tags

laravelresizeimagesresponsivesrcsetWebp

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/emiliolodigiani-laravel-images/health.svg)

```
[![Health](https://phpackages.com/badges/emiliolodigiani-laravel-images/health.svg)](https://phpackages.com/packages/emiliolodigiani-laravel-images)
```

###  Alternatives

[intervention/image-laravel

Laravel Integration of Intervention Image

1558.1M159](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

506511.0k27](/packages/bkwld-croppa)[ayvazyan10/nova-imagic

Imagic is a Laravel Nova field package that allows for image manipulation capabilities, such as cropping, resizing, quality adjustment, and WebP conversion. It utilizes the powerful Intervention Image class for image manipulation.

144.4k1](/packages/ayvazyan10-nova-imagic)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
