2017 © Pedro Peláez
 

library icr

Image manipulation and upload module

image

todstoychev/icr

Image manipulation and upload module

  • Saturday, August 13, 2016
  • by todstoychev
  • Repository
  • 1 Watchers
  • 2 Stars
  • 621 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 23 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

This is an image manipulation module based on the Imagine module. It is for Laravel 5.* php framework., (*2)

Installation

Use the standard composer way:, (*3)

composer require todstoychev/icr

Or add to your composer.json:, (*4)

"require": {
    ...
    "todstoychev/icr": "dev-master",
    ...
    }

and run, (*5)

composer update, (*6)

Configuration

In the 'providers' section of your Laravel config/app.php add: Todstoychev\Icr\ServiceProvider::class,., (*7)

In the 'aliases' you can add: 'Icr' => \Todstoychev\Icr\Icr::class,, (*8)

Run php artisan vendor:publish --provider="Todstoychev\Icr\ServiceProvider" to publish the config or you cal use also php artisan vendor:publish --tag=icr., (*9)

You will need also to set a new setting for the Storage module of Laravel. This can be done in the config/filesystem.php. You can create something similar:, (*10)

'local' => [
    'driver' => 'local',
    'root'   => public_path('/uploads/images'),
],

Put this one at the disks section of the file., (*11)

The config file

The file can be found in config/ it is called icr.php. The file contains several sections and parameters., (*12)

image_adapter

This is setting for the driver library that will be used to process the images. Imagine has support for Gd, Imagick and Gmagick, the available values are gd, imagick or gmagick., (*13)

Contexts

Those are the context settings. Each context is presented by array. The default one looks like this:, (*14)

'default' => [ 
        'small' => [
            'width' => 100,
            'height' => 100,
            'operation' => 'resize',
        ],
        'medium' => [
            'width' => 300,
            'height' => 300,
            'operation' => 'resize',
        ],
        'large' => [
            'width' => 600,
            'height' => 600,
            'operation' => 'resize',
        ],
    ],

Each context can define different sizes. The size array has 3 parameters: width, height and operation., (*15)

'small' => [
            'width' => 32,
            'height' => 32,
            'operation' => 'resize-crop',
        ],

Allowed operations are crop, resize, scale, resize-crop. - crop - crops region from the center of the provided image; - resize - resize image to given dimensions as keeps the proportions of the image; - scale - scales the image to given dimensions; - resize-crop - first resize the image while keeping the original proportions and then crops an region from the image center with the given size., (*16)

Methods

To use the module call its basic class - Icr. The class contain 2 methods. One to upload images, the other to delete. Another way to using it is to instantiate Todstoychev\Icr\Processor, (*17)

Upload image

The Icr::uploadImage() method returns the file name on success. if any errors it returns an exception class instance. You can use something similar in your controller method:, (*18)

$response = Icr::uploadImage($request->file('image'), 'my_context', 'images');

if ($response instanceof \Exception) {
    // Handle the error
} else {
    // Save the image name to database. Example: $myModel->saveImage($response);
}

As first argument you should use what is coming as file from the request, second argument is the context. The third argument is your setting name from the config/filesystem.php., (*19)

Delete image

This can be performed with Icr::deleteImage(). Example:, (*20)

$response = Icr::deleteImage('my_file_name', 'my_context', 'images');

if ($response instanceof \Exception) {
    // Handle the error
} else {
    // Delete the image name from database. Example: $myModel->deleteImage($response);
}

Parameters are the same as in the uploadImage() method, except the first one which is the file name of the file that should be deleted., (*21)

The Versions

13/08 2016

dev-master

9999999-dev https://github.com/todstoychev/icr

Image manipulation and upload module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Todor Todorov

13/08 2016

dev-develop

dev-develop https://github.com/todstoychev/icr

Image manipulation and upload module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Todor Todorov

13/08 2016
13/08 2016
13/08 2016
24/07 2016
24/07 2016
11/06 2016
08/06 2016
07/06 2016
07/06 2016
07/06 2016

0.2.2-alpha

0.2.2.0-alpha https://github.com/todstoychev/icr

Image manipulation and upload module

  Sources   Download

MIT

The Requires

 

The Development Requires

by Todor Todorov

15/03 2016
22/02 2016
12/02 2016

0.2.1-alpha

0.2.1.0-alpha https://github.com/todstoychev/icr

Image crop resizer based on Imagine module

  Sources   Download

MIT

The Requires

 

by Todor Todorov

image crop resizer scale image manipulation imagine

14/11 2015

v0.2.0-alpha

0.2.0.0-alpha https://github.com/todstoychev/icr

Image crop resizer based on Imagine module

  Sources   Download

MIT

The Requires

 

by Todor Todorov

image crop resizer scale image manipulation imagine

11/11 2015

v0.1.5-alpha

0.1.5.0-alpha https://github.com/todstoychev

Image crop resizer based on imagine

  Sources   Download

MIT

The Requires

 

by Todor Todorov

image resizer imagine

11/11 2015

v0.1.4-alpha

0.1.4.0-alpha https://github.com/todstoychev

Image crop resizer based on imagine

  Sources   Download

MIT

The Requires

 

by Todor Todorov

image resizer imagine

11/11 2015

v0.1.3-alpha

0.1.3.0-alpha https://github.com/todstoychev

Image crop resizer based on imagine

  Sources   Download

MIT

The Requires

 

by Todor Todorov

image resizer imagine

11/11 2015

v0.1.2-alpha

0.1.2.0-alpha https://github.com/todstoychev

Image crop resizer based on imagine

  Sources   Download

MIT

The Requires

 

by Todor Todorov

image resizer imagine

11/11 2015

v0.1.1-alpha

0.1.1.0-alpha https://github.com/todstoychev

Image crop resizer based on imagine

  Sources   Download

MIT

The Requires

 

by Todor Todorov

image resizer imagine

11/11 2015

v0.1.0-alpha

0.1.0.0-alpha https://github.com/todstoychev

Image crop resizer based on imagine

  Sources   Download

MIT

The Requires

 

by Todor Todorov

image resizer imagine