PHPackages                             clapp/imagerepository - 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. clapp/imagerepository

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

clapp/imagerepository
=====================

1.0.0-alpha1(8y ago)02381[6 issues](https://github.com/clappcom/imagerepository/issues)proprietaryPHPPHP ^5.5.9|~7.0

Since Nov 24Pushed 8y ago2 watchersCompare

[ Source](https://github.com/clappcom/imagerepository)[ Packagist](https://packagist.org/packages/clapp/imagerepository)[ RSS](/packages/clapp-imagerepository/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (6)Versions (3)Used By (0)

clapp/imagerepository [![Build Status](https://camo.githubusercontent.com/a344140234eca91a6a1a53fdf123cfe1d3d795ba099c38c1c315552eb68e714e/68747470733a2f2f7472617669732d63692e6f72672f636c617070636f6d2f696d6167657265706f7369746f72792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/clappcom/imagerepository) [![Coverage Status](https://camo.githubusercontent.com/066c7fe1a8dca2bd305432b0d5b2119d658e76c21513a50642827c27c5c09f65/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f636c617070636f6d2f696d6167657265706f7369746f72792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/clappcom/imagerepository?branch=master)
================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#clappimagerepository--)

Usage example (in Laravel)
--------------------------

[](#usage-example-in-laravel)

```
use Clapp\ImageRepository\ImageRepository;
use Clapp\ImageRepository\ImageMissingOrInvalidException;

class User {

    protected $profilePictureRepository = null;

    public function __construct(/* ... */){

        $this->profilePictureRepository = new ImageRepository('profile-pictures/');

        /* ... */
    }

    public function getProfilePicture($width=500, $height=500)
    {
        try {
            return $this->profilePictureRepository->get(array_get($this->attributes, 'profile_picture'), $width, $height);
        }catch(ImageMissingOrInvalidException $e){
            return $this->profilePictureRepository->get(resource_path('assets/images/placeholder.png'), $width, $height);
        }
    }

    public function setProfilePictureAttribute($pictureContents){
        $value = $pictureContents;
        if (!empty($value)){
            $value = $this->profilePictureRepository->put($value);
        }
        $this->attributes['profile_picture'] = $value;
    }
}
```

API reference
-------------

[](#api-reference)

- [`ImageRepository::__construct($storagePrefix = "", $storageDisk = null, $cacheDisk = null, ImageManager $imageManager = null)`](#imagerepository__constructstorageprefix---storagedisk--null-cachedisk--null-imagemanager-imagemanager--null)
- [`ImageRepository::put($imageContents)`](#imagerepositoryputimagecontents)
- [`ImageRepository::get($key, $width = 500, $height = 500)`](#imagerepositorygetkey-width--500-height--500)
- `ImageRepository::remove($key)`
- `ImageRepository::flush()`

### `ImageRepository::__construct($storagePrefix = "", $storageDisk = null, $cacheDisk = null, ImageManager $imageManager = null)`

[](#imagerepository__constructstorageprefix---storagedisk--null-cachedisk--null-imagemanager-imagemanager--null)

Create a new ImageRepository instance.

Params:

- `$storagePrefix`: `string` a prefix to allow multiple collections on the same $storageDisk and $cacheDisk - e.g. `"user-profile-pictures"`
- `$storageDisk`: `Illuminate\Contracts\Filesystem\Filesystem` a disk to store the original images
- `$cacheDisk`: `Illuminate\Contracts\Filesystem\Filesystem` a disk to store the generated image thumbnails
- `$imageManager`: `Intervention\Image\ImageManager` ImageManager to use for image manipulation

### `ImageRepository::put($imageContents)`

[](#imagerepositoryputimagecontents)

Store an image into the ImageRepository instance.

Params:

- `$imageContents`: `mixed` any image format that Intervention\\Image\\ImageManager::make() can parse

Returns:

- `string` $key that can be used to retrieve the image from `get()`

### `ImageRepository::get($key, $width = 500, $height = 500)`

[](#imagerepositorygetkey-width--500-height--500)

Params:

- `$key`: `string` key from `put()` OR an absolute path to an image file on your local disk (for placeholders)
- `$width`: `int` fit the image into this width (default: 500)
- `$height`: `int` fit the image into this height (default: 500)

Returns:

- `string` path to the generated image from the base of the $cacheDisk - can be put immediately into laravel's `asset()` function

### `ImageRepository::get($key, Closure $transform, Closure $transformId)`

[](#imagerepositorygetkey-closure-transform-closure-transformid)

Params:

- `$key`: `string` key from `put()` OR an absolute path to an image file on your local disk (for placeholders)
- `$transform`: `Closure` use this function to apply custom transformations to the image
- `$transformId`: `Closure` use this function to generate a unique string for the custom transformation - the same transformation should have the same unique string

Example:

```
$image = $repo->get($key, function($image){
    $image->resize(123, null, function($constraint){
        $constraint->aspectRatio();
    });
    return $image;
}, function(){
    return "123_auto";
});
```

Returns:

- `string` path to the generated image from the base of the $cacheDisk - can be put immediately into laravel's `asset()` function

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95% 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

Unknown

Total

1

Last Release

3217d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5737250?v=4)[Gergely Sárosi](/maintainers/dsge)[@dsge](https://github.com/dsge)

---

Top Contributors

[![dsge](https://avatars.githubusercontent.com/u/5737250?v=4)](https://github.com/dsge "dsge (19 commits)")[![creever](https://avatars.githubusercontent.com/u/1244590?v=4)](https://github.com/creever "creever (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/clapp-imagerepository/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[laravel-at/laravel-image-sanitize

A small but handy package to prevent malicious code execution coming into your application through uploaded image files.

29063.8k](/packages/laravel-at-laravel-image-sanitize)[danihidayatx/image-optimizer

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

3113.6k](/packages/danihidayatx-image-optimizer)[intervention/image-driver-vips

libvips driver for Intervention Image

47144.1k10](/packages/intervention-image-driver-vips)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4923.6k5](/packages/ralphjsmit-laravel-glide)

PHPackages © 2026

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