PHPackages                             onigoetz/imagecache - 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. onigoetz/imagecache

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

onigoetz/imagecache
===================

Image manipulation &amp; caching for everybody

3.1.0(8mo ago)73.7k3[1 issues](https://github.com/onigoetz/imagecache/issues)MITPHPPHP &gt;=8.0CI passing

Since Jan 15Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/onigoetz/imagecache)[ Packagist](https://packagist.org/packages/onigoetz/imagecache)[ RSS](/packages/onigoetz-imagecache/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (9)Versions (15)Used By (0)

Imagecache
==========

[](#imagecache)

[![Latest Version](https://camo.githubusercontent.com/e68b88f8f146dac04da2519774283ce3089e7ebe5e7806026df843e4f017e2b7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6f6e69676f65747a2f696d61676563616368652e7376673f7374796c653d666c61742d737175617265)](https://github.com/onigoetz/imagecache/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/onigoetz/imagecache/blob/master/LICENSE.md)[![Build Status](https://camo.githubusercontent.com/2a54792b4a475b8d4ba5f948efed55fd85e3bb78b88d960fd699fa8d9f1fedcd/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6f6e69676f65747a2f696d61676563616368652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/onigoetz/imagecache)[![Coverage Status](https://camo.githubusercontent.com/cb30a3c9b15125070c1b2a8c8c98ff2c8b0d671dcdcf73cd4b9d36ff5c6eeefb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6f6e69676f65747a2f696d61676563616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/onigoetz/imagecache/code-structure)[![Quality Score](https://camo.githubusercontent.com/7f88b859f89320f046520969a0564b90ed5c008026323314c4e7027103235183/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6f6e69676f65747a2f696d61676563616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/onigoetz/imagecache)[![Total Downloads](https://camo.githubusercontent.com/ab2d3516ebbf3c04fce95da3d51f8c254cecc8c2e84feaa3dd8ed0deded5be89/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6e69676f65747a2f696d61676563616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/onigoetz/imagecache)

Automatically generate images at the size you need them with presets

**Works with any framework**

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

[](#how-it-works)

Provided your images folder is `images`, your cache folder is `cache` and you have a preset called `200x200`

When you call the url `/images/cache/200x200/image.jpg` and the file doesn't exist it will automatically take the file `images/image.jpg`, apply the preset to it, return it to the client and save it at the request's path to serve it from the webserver the next time.

Here is the folder structure:

```
images
├── image.jpg          // Original image
└── cache
    └── 200x200
        └── image.jpg  // Generated image using the `200x200` preset

```

An url to a cached image is built as follows :

`////`

Image files can be in sub-folders, for example `images/avatars/me.jpg` will have this url with a `40x40` preset : `images/cache/40x40/avatars/me.jpg`

Prerequisites
-------------

[](#prerequisites)

For it to work you need

- PHP 5.5
- Clean urls with apache url\_rewrite or nginx rewrites

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

[](#installation)

- [Laravel 5](http://github.com/onigoetz/imagecache/tree/master/docs/laravel5.md)
- [Slim Framework 3](http://github.com/onigoetz/imagecache/tree/master/docs/slim3.md)
- [Raw PHP](http://github.com/onigoetz/imagecache/tree/master/docs/raw.md)

Preset configuration
--------------------

[](#preset-configuration)

The most important part of the module, the presets.

They're made of a a key with an array of actions to apply.

The key is the name of the preset you will use in the URL.

> My recommendation is to put the size of the final image in the preset name, this allows for more reusability in your presets. Because if you create a rule named for example "thumbnails" and that your layout changes the sizes of your thumbnails but only in some places, you'll soon end up with a mess with your preset names.

**Preset structure**

```
'name' => [
    action,
    action ...
]
```

**Action structure**

```
['action' => 'action_name', ... options ...]
```

[Complete list of actions and options](http://github.com/onigoetz/imagecache/tree/master/docs/actions.md)

### Example

[](#example)

```
'presets' => [
    '40X40' => [   // Exact size
        ['action' => 'scale_and_crop', 'width' => 40, 'height' => 40]
    ],
    'X85' => [     // Fixed height
        ['action' => 'scale', 'height' => 85]
    ],
    '60X200' => [  // Scale to fit inside
        ['action' => 'scale', 'height' => 200, 'width' => 60]
    ],
]
```

Retina Images
-------------

[](#retina-images)

This package also helps to generate image for retina displays. there are two ways for this.

With plugins like [retina.js](http://retinajs.com/) the page will automatically try urls with **@2x** just before the extension.

When a normal image's url is `/images/cache/200x200/koala.jpg` it will resolve to the original file `koala.jpg`.

But if you call the url `/images/cache/200x200/koala@2x.jpg` it will also resolve to the file `koala.jpg`.

This will take the `200x200` preset and double all it's values, so if you crop your images to 200x200 pixels, it will now be a 400x400 pixels image.

And it will save it back to `images/cache/200x200/koala@2x.jpg` so your apache/nginx will be able to serve it on next visit.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance74

Regular maintenance activity

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 95.7% 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 ~472 days

Recently: every ~748 days

Total

10

Last Release

251d ago

Major Versions

1.2.1 → 2.0.02016-11-17

2.1.1 → 3.0.02024-07-22

PHP version history (4 changes)1.0.0PHP &gt;=5.3.0

1.1.0PHP &gt;=5.4.0

1.2.0PHP &gt;=5.5.0

3.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7766264b40bb3a40b9b2ac847b67135c59e774807a6d1e313758efcd8203603f?d=identicon)[onigoetz](/maintainers/onigoetz)

---

Top Contributors

[![onigoetz](https://avatars.githubusercontent.com/u/309594?v=4)](https://github.com/onigoetz "onigoetz (88 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (3 commits)")[![thattomperson](https://avatars.githubusercontent.com/u/1112472?v=4)](https://github.com/thattomperson "thattomperson (1 commits)")

---

Tags

laravelimageslimlaravel 5Laravel 4retinaautomatic generation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/onigoetz-imagecache/health.svg)

```
[![Health](https://phpackages.com/badges/onigoetz-imagecache/health.svg)](https://phpackages.com/packages/onigoetz-imagecache)
```

###  Alternatives

[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[joshembling/image-optimizer

Optimize your Filament images before they reach your database.

111145.4k12](/packages/joshembling-image-optimizer)[urlbox/screenshots

Use urlbox to easily generate website thumbnail screenshots from a URL

14250.4k](/packages/urlbox-screenshots)[danihidayatx/image-optimizer

Optimize your Filament images before they reach your database. Forked from joshembling/image-optimizer for Filament v4 &amp; v5 support.

254.4k](/packages/danihidayatx-image-optimizer)

PHPackages © 2026

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