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

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

ankitpokhrel/laravel-image
==========================

Easy image upload and thumbnail management

v0.0.1(9y ago)382336MITPHPPHP &gt;=5.6.4

Since Sep 11Pushed 9y ago7 watchersCompare

[ Source](https://github.com/ankitpokhrel/laravel-image)[ Packagist](https://packagist.org/packages/ankitpokhrel/laravel-image)[ RSS](/packages/ankitpokhrel-laravel-image/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (6)Versions (5)Used By (0)

Laravel Image
=============

[](#laravel-image)

[![Latest Version](https://camo.githubusercontent.com/2b3c23b82ac6de56f254df227ea9ff6b57dc7286d4befe77c0e0784420265dc3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f616e6b6974706f6b6872656c2f6c61726176656c2d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://github.com/ankitpokhrel/laravel-image/releases)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/18d6982d9a881a0207aaf8111223de94fce69c66d92071f8c6ce426e0d2efb6c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616e6b6974706f6b6872656c2f6c61726176656c2d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ankitpokhrel/laravel-image/?branch=master)[![Travis Build](https://camo.githubusercontent.com/145b7b4cf8526130bca4aa5125d7cc1c9bb9a9ef2bc5b79980fcffdbc937e461/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f616e6b6974706f6b6872656c2f6c61726176656c2d696d6167652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ankitpokhrel/laravel-image?branch=master)[![Code Coverage](https://camo.githubusercontent.com/b9014cb81f80950c0cd0cbcf92da572a7dc5f66881054b95ac84e9b83f6dbf7f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f616e6b6974706f6b6872656c2f6c61726176656c2d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ankitpokhrel/laravel-image/?branch=master)[![StyleCI](https://camo.githubusercontent.com/afc62505259c6c6a8d889c7321629b1e09276e1509b4ce053ef8aa2dce43e482/68747470733a2f2f7374796c6563692e696f2f7265706f732f36313939323834312f736869656c64)](https://styleci.io/repos/61992841)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/0710be97a2a1697dbe02c0d05f2fd816c3d99cc9fe1b853ba8b14e7c68445cf9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e6b6974706f6b6872656c2f6c61726176656c2d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ankitpokhrel/laravel-image)

*Image Upload Package for Laravel 5+*

Overview
--------

[](#overview)

Laravel Image is a image upload and thumbnail management package for laravel 5+. This package uses [Glide](http://glide.thephpleague.com/) library from the php league for on-demand image manipulation.

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

[](#installation)

> For 5.1 use [5.1](https://github.com/ankitpokhrel/laravel-image/tree/5.1) branch.
> For 5.2 use [5.2](https://github.com/ankitpokhrel/laravel-image/tree/5.2) branch.
> For 5.3 use [master](https://github.com/ankitpokhrel/laravel-image) branch.

Pull the package via composer

```
composer require ankitpokhrel/laravel-image
```

Include the service provider within `config/app.php`.

```
AnkitPokhrel\LaravelImage\ImageUploadServiceProvider::class
```

Finally publish the configuration

```
php artisan vendor:publish --provider="AnkitPokhrel\LaravelImage\ImageUploadServiceProvider"
```

Configuration
-------------

[](#configuration)

You can add default configurations to `config/laravelimage.php`.

Usage
-----

[](#usage)

#### Uploading Image

[](#uploading-image)

Within your controllers, get access to image upload service via dependency injection

```
class ContentsController extends Controller
{
    ...

    protected $image;

    /**
     * @param ImageUploadService $image
     */
    public function __construct(ImageUploadService $image)
    {
        ...

        //set properties for file upload
        $this->image = $image;
        $this->image->setUploadField('image'); //default is image
        $this->image->setUploadFolder('contents'); //default is public/uploads/contents
    }

    ...
```

And then, in your store or update method you can perform image upload

```
/**
 * Store method
 */
public function store(ContentRequest $request)
{
    $input = $request->all();

    if (Input::hasFile($this->image->getUploadField()) && $this->image->upload()) {
        //image is uploaded, get uploaded image info
        $uploadedFileInfo = $this->image->getUploadedFileInfo();

        ...
        //do whatever you like with the information
        $input = array_merge($input, $uploadedFileInfo);
    } else {
        //get validator object
        $validator = $this->image->getValidationErrors();

        //get error messages
        $errors = $validator->messages()->all();
    }

    ...
}

/**
 * Update method
 */
public function update(Request $request, $id)
{
    ...

    if (Input::hasFile($this->image->getUploadField()) && $this->image->upload()) {
        ...

        //remove old files
        if (!empty(trim($model->file_path))) {
            $this->image->clean(public_path($model->file_path), true);
        }
    }

    ...
}
```

#### Uploaded file info

[](#uploaded-file-info)

You can get uploaded file info using `$this->image->getUploadedFileInfo()`. It will return array as follow:

```
image               : Saved image name
upload_dir          : Image upload path
original_image_name : Real name of uploaded image
size                : Size of the uploaded image
extension           : Extension of the uploaded image
mime_type           : Mime type of the uploaded image
```

To change `image` field you can use `setUploadField()` method. If you wish to change `upload_dir` field you can use `setUploadDir` method. Usually you will save `image`, `upload_dir` and `original_image_name` to the database.

To get validation errors, you can use `getValidationErrors()` method.

#### Customizing upload path

[](#customizing-upload-path)

Sometime you may want to group uploaded image or even store image somewhere else other than the public folder. You can do it by setting base path. For example, this settings below will store images inside `public/uploads/user-images/users/` directory.

```
//set base path
$this->image->setBasePath('uploads/user-images/');

//set upload folder
$this->image->setUploadFolder('users');
```

If you want to upload image in other places other than `public` folder, you can provide second parameter as `false`to the base path method.

```
//set absolute base path
$this->image->setBasePath('/absolute/path/to/your/folder/uploads/', true);

//set upload folder
$this->image->setUploadFolder('users');
```

This will upload image to `/absolute/path/to/your/folder/uploads/users` folder. Make sure that the folder has proper permission to store the images.

#### Using blade directive to display images

[](#using-blade-directive-to-display-images)

Display full image

```
@laravelImage($uploadDir, $imageName)
```

Create image of custom size at runtime

```

@laravelImage($uploadDir, $imageName, 300, 200)
```

Options &amp; attributes

```

@laravelImage($uploadDir, $imageName, 300, 200, [
    'fit' => 'crop-top-left',
    'filt' => 'sepia'
], [
    'alt' => 'Alt text of an image',
    'class' => 'custom-class'
])
```

> Options can be any glide options. See [thephpleague/glide](http://glide.thephpleague.com/) for more info on options.

#### Displaying image without blade

[](#displaying-image-without-blade)

Image source should be in the format `laravelimage.routePath/uploadDir/image?options`, where `laravelimage.routePath` is from configuration file. So if you set your `routePath` to `cache`, the image url will be something like this.

```

```

Generated images are cached inside `storage/laravel-image-cache`.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.6% 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 ~11 days

Total

3

Last Release

3509d ago

Major Versions

v0.0.1 → 5.2.x-dev2016-10-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/07f2aef5d1e12e750ce5f46b0f7d845fc134b911511fb6b46eddda8a1a783152?d=identicon)[ankitpokhrel](/maintainers/ankitpokhrel)

![](https://www.gravatar.com/avatar/9013467fc76680ffe54b1ce45bcb3f509ee964dc2edef5cae2172a72bdb2ad5b?d=identicon)[samundra](/maintainers/samundra)

---

Top Contributors

[![ankitpokhrel](https://avatars.githubusercontent.com/u/2364546?v=4)](https://github.com/ankitpokhrel "ankitpokhrel (80 commits)")[![samundra](https://avatars.githubusercontent.com/u/760855?v=4)](https://github.com/samundra "samundra (1 commits)")[![stevendesu](https://avatars.githubusercontent.com/u/1384974?v=4)](https://github.com/stevendesu "stevendesu (1 commits)")

---

Tags

glideimage-manipulationlaravellaravel-5-packagelaravel-image

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-image-optimizer

Optimize images in your Laravel app

1.3k6.5M43](/packages/spatie-laravel-image-optimizer)[area17/twill-image

3148.6k](/packages/area17-twill-image)[justbetter/statamic-image-optimize

Image optimization after upload

1315.2k](/packages/justbetter-statamic-image-optimize)[sukohi/surpass

A PHP package mainly developed for Laravel to manage uploading images using Ajax and displaying thumbnail.

283.8k](/packages/sukohi-surpass)

PHPackages © 2026

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