PHPackages                             bertvthul/cropper - 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. bertvthul/cropper

ActiveLibrary

bertvthul/cropper
=================

Simple upload and crop images in Laravel

03PHP

Since Oct 16Pushed 4y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Simple upload and crop images in Laravel
========================================

[](#simple-upload-and-crop-images-in-laravel)

A simple uploader for your images in Laravel. No database columns needed, due to saving the images using the field name, the id and using the model name as the folder to save in.

```
@cropper('avatar', 'App\User')
```

In the associated model you set up the preferences;

```
use Bertvthul\Cropper\HasCropper;

class User
{
    use HasCropper;

    public static $cropper = [
        'avatar' => [
            'validation' => [
                'required' => true,
            ],
            'width' => 200,
            'height' => 200,
        ],
    ];
```

Images are automatically saved in a folder with the model name. The filenames are formatted using the id and the fieldname;

```
public
    images
        user
            1-avatar.jpg
            1-avatar-orig.jpg

```

The original file is saved (`-orig` at the end), in a max of 2000x2000 pixels, for later resizing. So when editing an item, you can recrop the uploaded image.

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

[](#installation)

You can install the package via composer:

```
composer require bertvthul/cropper
```

Add the service provider to the providers array in `config\app.php`;

```
Bertvthul\Cropper\CropperServiceProvider::class,
```

Also make sure the js and css are loaded, by adding them to app.js and app.scss;

```
require('./../../vendor/bertvthul/cropper/src/js/cropper.js');
```

```
@import './../../vendor/bertvthul/cropper/src/css/cropper.scss';
```

Publish the files, like the config (optional)

```
php artisan vendor:publish --provider=Bertvthul\Cropper\CropperServiceProvider
```

Usage
-----

[](#usage)

In your blade file you can add the upload field;

```
@cropper('avatar', 'App\User', ['class' => 'form-control', 'id' => $user->id])
```

In this example the fieldname is `avatar`. As a second parameter define the model that is associated, where you can define the settings. The third parameter is optional for passing settings. Supported settings are;

```
[
    'class' => 'form-control', // separated by spaces
    'id' => $user->id, // useful when the right id isn't auto discovered
]
```

In the model you can set up the preferences in a `$cropper` variable, where the key is the name of the field;

```
use Bertvthul\Cropper\HasCropper;

class User
{
    use HasCropper;

    public static $cropper = [
        'avatar' => [
            'width' => 200,
            'height' => 200,
        ],
        'cover' => [
            'width' => 1600,
            'height' => 600,
            'validation' => [
                'required' => false,
            ]
        ]
    ];
```

In this example the fieldname is `avatar`. Default field settings are;

```
'validation' => [
    'filetypes' => 'jpeg,png,jpg,gif,svg',
    'max'       => 20480, // 20 mb
    'required'  => true,
],
'width' => 200,
'height' => 200,
'upload-text' => 'Upload',
```

In your blade files, you can simply use the image getter;

```

```

Available are;

- path
- path\_original (path to the original uncropped image)
- ext
- name

Features
--------

[](#features)

###### Inline editing

[](#inline-editing)

Editing the images is also possible inline. This means you don't have to place it in a form. The package then saves the changes on the fly. Usefull when you want users to easily update their image.

###### No database columns needed

[](#no-database-columns-needed)

Using a logical naming convention, so no need to save the image in the database.

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity28

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/78cc1b2a38a163e940efcbceac68e6b90912f4652b475dc877fb8faf506d6914?d=identicon)[bertvthul](/maintainers/bertvthul)

---

Top Contributors

[![bertvthul](https://avatars.githubusercontent.com/u/1345057?v=4)](https://github.com/bertvthul "bertvthul (12 commits)")

### Embed Badge

![Health badge](/badges/bertvthul-cropper/health.svg)

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

PHPackages © 2026

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