PHPackages                             raiika/laravel-single-image - 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. raiika/laravel-single-image

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

raiika/laravel-single-image
===========================

Easy image manipulation on Laravel Model

00PHPCI failing

Since Sep 26Pushed 6y agoCompare

[ Source](https://github.com/raiika/laravel-single-image)[ Packagist](https://packagist.org/packages/raiika/laravel-single-image)[ RSS](/packages/raiika-laravel-single-image/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-SingleImage
===================

[](#laravel-singleimage)

This trait is dependence of Intervention Image

The goal is the same as the name, only support single image on a model

in Controller
=============

[](#in-controller)

Basic use is

```
$model = new Model();
$model->image   = $request->image;

if ($needsCropping) {
    $model->cropper = $request->only('x', 'y', 'w', 'h');
    $model->cropper = [0,0,500,500]; // [x,y,w,h]
}

if ($manualSave) $model->saveImage();

$model->save(); // trigger auto image saving

$model->delete(); // trigger auto image deleting

```

in Model
========

[](#in-model)

These are all available config

```
protected $singleImage = [
        'dir' => $this->defaultDir(),
        'dimensions' => [
            'default' => [
                'w' => 500,
                'h' => 500,
                'upsize' => true,
                'aspectRatio' => false,
            ],
            'medium' => [
                'w' => 500,
                'h' => null,
                'upsize' => true,
                'aspectRatio' => false,
            ]
            'anything' => [
                'w' => 500,
                'h' => 500,
                'upsize' => true,
                'aspectRatio' => false,
            ]
        ],

        // if wants single dimension use below for readability
        'dimension' => [
            'w' => 500,
            'h' => 500,
            'upsize' => true,
            'aspectRatio' => false,
        ],

        'column' => 'image',
        'strict' => false,
        'disablePlaceholder' => false
]

```

Deleting Image
==============

[](#deleting-image)

in Controller

```
//by default, the trait will delete the image on model delete
$model->delete();

//if you wants to delete manually all image
$model->deleteImage();

//delete only small and medium image
$model->deleteImage('small', 'medium');

```

Implementing single or multi delete on query builder
====================================================

[](#implementing-single-or-multi-delete-on-query-builder)

```
Model::whereNotNull('deleted_at')->deleteImages();

```

Implementing single image
=========================

[](#implementing-single-image)

```
protected $singleImage = [
        'dimension' => [
                'w' => 500,
                'h' => 500,
                'upsize' => true,
                'aspectRatio' => false,
        ],
];

```

Implementing many image dimension (for thumb)
=============================================

[](#implementing-many-image-dimension-for-thumb)

default is a must (it is called when you dont specify what folder u want to use) or you could set on key \['dimension'\] like the single image above and it automatically moved to \['dimensions'\]\['default'\]

```
protected $singleImage = [
        'dimensions' => [
            'default' => [
                'w' => 500,
                'h' => 500,
                'upsize' => true,
                'aspectRatio' => false,
            ],
            'medium' => [
                'w' => 500,
                'h' => null,
                'upsize' => true,
                'aspectRatio' => false,
            ],
            'small' => [
                'w' => 500,
                'h' => null,
                'upsize' => true,
                'aspectRatio' => false,
            ],
            'up-to-you' => [
                'w' => 500,
                'h' => null,
                'upsize' => true,
                'aspectRatio' => false,
            ],
        ],
];

```

boot
====

[](#boot)

this is the boot of the trait, it makes the image delete the old one and saved the new one on model save, and also delete the old image when the model is deleted

```
    static::saving(function($model){
        $model->deleteImage();
        $model->saveImage();
    });

    static::deleting(function($model){
        $model->deleteImage();
    });

```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/780e95812084e3cc54df8fb67f3f7df56df9dbcac2d23fef8fad6af33a05d215?d=identicon)[raiika](/maintainers/raiika)

---

Top Contributors

[![raiika](https://avatars.githubusercontent.com/u/33516651?v=4)](https://github.com/raiika "raiika (33 commits)")

### Embed Badge

![Health badge](/badges/raiika-laravel-single-image/health.svg)

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

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495225.1k1](/packages/char0n-ffmpeg-php)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)

PHPackages © 2026

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