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 4w ago

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

Maturity37

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

[goat1000/svggraph

Generates SVG graphs

135931.0k3](/packages/goat1000-svggraph)[stefangabos/zebra_image

A single-file, lightweight PHP library designed for efficient image manipulation featuring methods for modifying images and applying filters

138121.6k7](/packages/stefangabos-zebra-image)[treinetic/imageartist

ImageArtist is a php gd Wrapper which makes Image manipulation insanely easy, we introduce ImageArtist as Photoshop for php

8783.2k](/packages/treinetic-imageartist)[johncarter/filament-focal-point-picker

An image focal point picker for Filament Admin.

4431.7k1](/packages/johncarter-filament-focal-point-picker)[yk/laravel-ocr

A wrapper for gocr.

1356.6k](/packages/yk-laravel-ocr)

PHPackages © 2026

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