2017 © Pedro Peláez
 

library guided-image

Simplified and ready image manipulation for Laravel 5 via intervention image.

image

reliqarts/guided-image

Simplified and ready image manipulation for Laravel 5 via intervention image.

  • Saturday, June 30, 2018
  • by ReliQ
  • Repository
  • 0 Watchers
  • 5 Stars
  • 418 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • 3 % Grown

The README.md

Laravel Guided Image

Guided Image is an image utility package for Laravel based on Intervention Image., (*1)

Built For Laravel Build Status (all) Scrutinizer Codecov Maintainability License Latest Stable Version Latest Unstable Version, (*2)

 , (*3)

Guided Image for Laravel, (*4)

Key Features

  • On-the-fly image resizing
  • On-the-fly thumbnail generation
  • Image uploading
  • Smart image reuse; mitigating against double uploads and space resource waste.

Guided Image can be integrated seamlessly with your existing image model., (*5)

Guided Routes

The package provides routes for generating resized/cropped/dummy images. - Routes are configurable you you may set any middleware and prefix you want. - Generated images are cached to disk to avoid regenerating frequently accessed images and reduce overhead., (*6)

Image file reuse

For situations where different instances of models use the same image. - The package provides a safe removal feature which allows images to be detached and only deleted from disk if not being used elsewhere. - An overridable method is used to determine when an image should be considered safe to delete., (*7)

Installation & Usage

Installation

Install via composer; in console:, (*8)

composer require reliqarts/laravel-guided-image

or require in composer.json:, (*9)

{
    "require": {
        "reliqarts/laravel-guided-image": "^5.0"
    }
}

then run composer update in your terminal to pull it in., (*10)

Finally, publish package resources and configuration:, (*11)

php artisan vendor:publish --provider="ReliqArts\GuidedImage\ServiceProvider"

You may opt to publish only configuration by using the guidedimage-config tag:, (*12)

php artisan vendor:publish --provider="ReliqArts\GuidedImage\ServiceProvider" --tag="guidedimage-config"

Setup

Set the desired environment variables so the package knows your image model, controller(s), etc., (*13)

Example environment config:, (*14)

GUIDED_IMAGE_MODEL=Image
GUIDED_IMAGE_CONTROLLER=ImageController
GUIDED_IMAGE_ROUTE_PREFIX=image
GUIDED_IMAGE_SKIM_DIR=images

These variables, and more are explained within the config file., (*15)

And... it's ready! :ok_hand:, (*16)

Usage

To use Guided Image you must do just that from your Image model. :smirk:, (*17)

Implement the ReliqArts\GuidedImage\Contract\GuidedImage contract and use the ReliqArts\GuidedImage\Concern\Guided trait, e.g:, (*18)

use Illuminate\Database\Eloquent\Model;
use ReliqArts\GuidedImage\Concern\Guided;
use ReliqArts\GuidedImage\Contract\GuidedImage;

class Image extends Model implements GuidedImage
{
    use Guided;

    // ... properties and methods
}

See example here., (*19)

Implement the ReliqArts\GuidedImage\Contract\ImageGuide contract and use the ReliqArts\GuidedImage\Concern\Guide trait from your ImageController, e.g:, (*20)

use ReliqArts\GuidedImage\Contract\ImageGuide;
use ReliqArts\GuidedImage\Concern\Guide;

class ImageController extends Controller implements ImageGuide
{
    use Guide;
}

See example here., (*21)

Features

Safely Remove Image (dissociate & conditionally delete the image)

An guided image instance is removed by calling the remove method. e.g:, (*22)

$oldImage->remove($force);

$force is optional and is false by default., (*23)

You may retrieve guided links to resized or cropped images like so:, (*24)

// resized image:
$linkToImage = $image->routeResized([
    '550',      // width
    '_',        // height, 'null' is OK 
    '_',        // keep aspect ratio? true by default, 'null' is OK
    '_',        // allow upsize? false by default, 'null' is OK
]);

// thumbnail:
$linkToImage = $image->routeThumbnail([
    'crop',     // method: crop|fit
    '550',      // width
    '_',        // height
]);

NB: In the above example _ resolves to null., (*25)

Have a look at the GuidedImage contract for more info on model functions., (*26)

For more info on controller functions see the ImageGuide contract., (*27)

Routes

Your actually routes will depend heavily on your custom configuration. Here is an example of what the routes may look like:, (*28)

|| GET|HEAD | image/.dum//{width}-{height}/{color?}/{fill?}           | image.dummy           | App\Http\Controllers\ImageController@dummy       | web |
|| GET|HEAD | image/.res/{image}//{width}-{height}/{aspect?}/{upSize?}| image.resize          | App\Http\Controllers\ImageController@resized     | web |
|| GET|HEAD | image/.tmb/{image}//m.{method}/{width}-{height}         | image.thumb           | App\Http\Controllers\ImageController@thumb       | web |
|| GET|HEAD | image/empty-cache                                       | image.empty-cache     | App\Http\Controllers\ImageController@emptyCache  | web |

The Versions

30/06 2018

dev-master

9999999-dev

Simplified and ready image manipulation for Laravel 5 via intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

30/06 2018

v1.0.12

1.0.12.0

Simplified and ready image manipulation for Laravel 5 via intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

30/06 2018

dev-develop

dev-develop

Simplified and ready image manipulation for Laravel 5 via intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

30/06 2018

v1.0.11

1.0.11.0

Simplified and ready image manipulation for Laravel 5 via intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

03/09 2017

v1.0.10

1.0.10.0

Simplified and ready image manipulation for Laravel 5 via intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

27/03 2017

v1.0.9

1.0.9.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

05/03 2017

v1.0.8

1.0.8.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

13/02 2017

v1.0.7

1.0.7.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

16/01 2017

v1.0.6

1.0.6.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

29/11 2016

v1.0.5

1.0.5.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

15/11 2016

v1.0.4

1.0.4.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

15/11 2016

v1.0.3

1.0.3.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

04/11 2016

v1.0.2

1.0.2.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

26/10 2016

v1.0.1

1.0.1.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy

23/10 2016

v1.0.0

1.0.0.0

Simplified and ready image manipulation for Laravel 5 through intervention image.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ReliQ

laravel route image photo resize crop laravel5 generation thumb dummy