3.1 documentation

Latest Stable Version Total Downloads MIT License

Imagine (Wrapper) Component is a Laravel 5 package wrapper for Imagine.

  1. Version Compatibility
  2. Installation
  3. Configuration
  4. Usage
  5. Change Log

Version Compatibility

Laravel Imagine
4.0.x 2.0.x
4.1.x 2.1.x
4.2.x 2.2.x
5.0.x 3.0.x
5.1.x 3.1.x

Installation

To install through composer, simply put the following in your composer.json file:

{
    "require": {
        "orchestra/imagine": "~3.0"
    }
}

And then run composer install from the terminal.

Quick Installation

Above installation can also be simplify by using the following command:

composer require "orchestra/imagine=~3.0"

Configuration

Add Orchestra\Imagine\ImagineServiceProvider service provider in config/app.php.

'providers' => [

    // ...

    Orchestra\Imagine\ImagineServiceProvider::class,
],

Aliases

Add Orchestra\Imagine\Facade facade alias in config/app.php.

'aliases' => [

    // ...

    'Imagine' => Orchestra\Imagine\Facade::class,
],

Usage

Here a simple example how to create a thumbnail from an image:

<?php

use Imagine\Image\Box;
use Imagine\Image\ImageInterface;

function create_thumbnail($path, $filename, $extension)
{
    $width  = 320;
    $height = 320;
    $mode   = ImageInterface::THUMBNAIL_OUTBOUND;
    $size   = new Box($width, $height);

    $thumbnail   = Imagine::open("{$path}/{$filename}.{$extension}")->thumbnail($size, $mode);
    $destination = "{$filename}.thumb.{$extension}";

    $thumbnail->save("{$path}/{$destination}");
}