PHPackages                             flobbos/laravel-image-cache - 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. flobbos/laravel-image-cache

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

flobbos/laravel-image-cache
===========================

Replacement for the now abandoned imagecache package by Intervention

v2.0.0(1mo ago)0155↓87.5%MITPHPPHP ^8.2CI failing

Since Apr 2Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Flobbos/laravel-image-cache)[ Packagist](https://packagist.org/packages/flobbos/laravel-image-cache)[ RSS](/packages/flobbos-laravel-image-cache/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (5)Dependencies (12)Versions (7)Used By (0)

Laravel Image Cache
===================

[](#laravel-image-cache)

Laravel Image Cache is a package that provides an easy-to-use caching mechanism for image manipulation in Laravel. It serves as a replacement for the now-abandoned imagecache package by Intervention.

Features
--------

[](#features)

- Cache manipulated images for improved performance.
- Support for multiple image drivers: GD, Imagick, and Libvips.
- Define custom image manipulation templates via a clean interface.
- Configurable cache lifetime and output formats (JPEG, PNG, GIF, WebP, AVIF).
- Dynamic routing for serving cached images.

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

[](#installation)

1. Install the package via Composer:

    ```
    composer require flobbos/laravel-image-cache
    ```
2. Publish the configuration file:

    ```
    php artisan vendor:publish --tag=config --provider="Flobbos\LaravelImageCache\ImageCacheServiceProvider"
    ```
3. Configure the `config/imagecache.php` file as needed.

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

To use the package, you can define templates in the configuration file and use the `ImageCache` facade to generate cached images.

```
use Flobbos\LaravelImageCache\Facades\ImageCache;

// Apply the "small" template to an image
$cachedImage = ImageCache::template('path/to/image.jpg', 'small');
```

### Dynamic Image Routes

[](#dynamic-image-routes)

The package provides a dynamic route for serving cached images. For example:

```
/images/{template}/{path}

```

- `template`: The name of the template defined in the configuration file.
- `path`: The relative path to the image in the configured paths.

Example URL:

```
http://your-app.test/images/small/example.jpg

```

### Custom Templates

[](#custom-templates)

Create a class that implements `TemplateInterface`:

```
namespace App\ImageTemplates;

use Flobbos\LaravelImageCache\Contracts\TemplateInterface;
use Intervention\Image\Interfaces\ImageInterface;

class CustomTemplate implements TemplateInterface
{
    public function build(ImageInterface $image): void
    {
        $image->resize(800, 600);
    }
}
```

Then, register the template in the `config/imagecache.php` file:

```
'templates' => [
    'custom' => \App\ImageTemplates\CustomTemplate::class,
],
```

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

[](#configuration)

The configuration file `config/imagecache.php` allows you to customize:

- **lifetime**: Cache lifetime in minutes. Set to `0` to cache forever.
- **driver**: Image processing driver (`gd`, `imagick`, or `libvips`).
- **store**: Cache store to use (from your Laravel cache config).
- **format**: Default output format (`jpg`, `png`, `gif`, `webp`, `avif`).
- **quality**: Encoder quality (1–100) for JPEG/WebP/AVIF. `null` uses Intervention defaults.
- **return\_object**: Whether to return an Intervention Image object or the encoded bytes.
- **templates**: Image manipulation templates (must implement `TemplateInterface`).
- **paths**: Directories to search for images (see below).
- **dynamic\_route**: The URL prefix for the dynamic image route.

### Paths

[](#paths)

You can specify one or more directories where the package should look for images.
Example from `config/imagecache.php`:

```
'paths' => [
    public_path('images'),
    storage_path('app/public/images'),
],
```

When a request is made, the package will search these directories for the requested image file in the order listed.

### Dynamic Image Routes

[](#dynamic-image-routes-1)

By default, the package registers a dynamic route for serving cached images:

```
/images/{template}/{path}

```

- `template`: The name of the template defined in your configuration.
- `path`: The relative path to the image file.

**Example URL:**

```
http://your-app.test/images/small/example.jpg

```

#### Customizing the Route

[](#customizing-the-route)

You can change the route prefix by editing the `route` option in `config/imagecache.php`:

```
'dynamic_route' => 'imgcache',
```

This will make your URLs look like:

```
http://your-app.test/imgcache/small/example.jpg

```

The route is named `imagecache.serve`, so you can also generate URLs with:

```
route('imagecache.serve', ['template' => 'small', 'path' => 'example.jpg']);
```

Security
--------

[](#security)

The dynamic route resolves the requested image against the configured `paths`using `realpath()` and refuses any request whose canonical path escapes the configured base directories. Path traversal attempts (e.g. `../../etc/passwd`) return a 404.

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 10, 11, 12, or 13
- Intervention Image 3.0 or higher

### Supported versions

[](#supported-versions)

The package declares broad version constraints, but the actual PHP × Laravel matrix exercised in CI is:

PHPLaravel 10Laravel 11Laravel 12Laravel 138.2✓✓✓— (L13 requires PHP 8.3+)8.3✓✓✓✓8.4— (L10 predates PHP 8.4)✓✓✓License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Credits
-------

[](#credits)

- Developed by Alexej Krzewitzki ()
- Inspired by the original imagecache package by Intervention

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance94

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~106 days

Total

5

Last Release

31d ago

Major Versions

v0.0.3 → v1.0.02026-04-07

v1.0.0 → v2.0.02026-06-03

PHP version history (2 changes)v0.0.1PHP ^8.1

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/74704c23d1a3ea66e1ddd18de4e90635ea4a2c28838e72ad49ba947694f7988e?d=identicon)[Flobbos](/maintainers/Flobbos)

---

Top Contributors

[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (5 commits)")[![Flobbos](https://avatars.githubusercontent.com/u/21225457?v=4)](https://github.com/Flobbos "Flobbos (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/flobbos-laravel-image-cache/health.svg)

```
[![Health](https://phpackages.com/badges/flobbos-laravel-image-cache/health.svg)](https://phpackages.com/packages/flobbos-laravel-image-cache)
```

###  Alternatives

[intervention/image-laravel

Laravel Integration of Intervention Image

1588.9M182](/packages/intervention-image-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5443.8k](/packages/hasinhayder-tyro-dashboard)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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