soumen-dey/laravel-image

A package to encode and generate thumbnail for Laravel 5.6 and above.

v1.0 2019-02-10 16:55 UTC

This package is not auto-updated.

Last update: 2024-05-01 02:08:35 UTC


README

Latest Version on Packagist Total Downloads

A package to encode and store your Uploaded Images for Laravel 5.6 and above.

Installation

Via Composer

This package depends on intervention/image

$ composer require soumen-dey/laravel-image

Laravel Auto-Discovery will automatically detect and add the Service Provider and Alias for the package. If it doesn't, do the following:

In the $providers array add the service providers for this package.

Soumen\Image\ImageServiceProvider::class

Add the facade of this package to the $aliases array.

'Image' => Soumen\Image\Facades\Image::class

Configuration

By default this packages uses GD library for processing the images, to change this behaviour and also to modify the default storage options, publish the configuration file for this package.

$ php artisan vendor:publish --provider="Soumen\Image\ImageServiceProvider"

Usage

use Soumen\Image

$file = $request->file('file');

// This will initialize and extract meta-data from the image
$image = new Image($file);

// This will encode the image and generate thumbnail
$image->process();

// Store the image in the storage
$image->store();

You can also use method chaining to write the above code in one line.

$image = (new Image($file))->process()->store();

You can also specify parameters.

$image = new Image($file);
$image->setQuality(90); // the jpeg image quality, default is 50
$image->setEncoding('png'); // default is jpeg
$image->setStorage('images'); // set the storage
$image->generateThumbnail(); // generates the thumbnail
$image->encode();
$image->store();

Do not use $image->process() if you wish specify parameters.

You can also use method chaining on the above code.

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.