mews/thumb

PHPThumb Package for Laravel 4 (Personal version)

dev-master 2014-01-10 20:30 UTC

This package is auto-updated.

Last update: 2024-11-29 04:14:13 UTC


README

A simple Laravel 4 service provider for including the PHPThumb for Laravel 4.

Installation

The PHPThumb Service Provider can be installed via Composer by requiring the mews/phpthumb package and setting the minimum-stability to dev (required for Laravel 4) in your project's composer.json.

{
    "require": {
        "laravel/framework": "4.0.*",
        "mews/thumb": "dev-master"
    },
    "minimum-stability": "dev"
}

Update your packages with composer update or install with composer install.

Usage

To use the PHPThumb Service Provider, you must register the provider when bootstrapping your Laravel application. There are essentially two ways to do this.

Find the providers key in app/config/app.php and register the PHPThumb Service Provider.

    'providers' => array(
        // ...
        'Mews\Thumb\ThumbServiceProvider',
    )

Find the aliases key in app/config/app.php.

    'aliases' => array(
        // ...
        'Thumb' => 'Mews\Thumb\Facades\Thumb',
    )

Example

    //[your site path]/app/routes.php

    Route::get('/media/image/{width}x{height}/{image}', function($width, $height, $image)
    {
        $file = base_path() . '/' . $image;
        // for remote file
        //$file = 'http://i.imgur.com/1YAaAVq.jpg';
        Thumb::create($file)->make('resize', array($width, $height))->show()->save(base_path() . '/', 'aaa.jpg');
        /*
            Thumb::create($file)->make('resize', array($width, $height))->make('crop', array('center', $width, $height))->show();
            Thumb::create($file)->make('resize', array($width, $height))->make('crop', array('basic', 100, 100, 300, 200))->show();
            Thumb::create($file)->make('resize', array($width, $height))->make('resize', array($width, $height))->show();
            Thumb::create($file)->make('resize', array($width, $height))->make('resize', array($width, $height, 'adaptive'))->save(base_path() . '/', 'aaa.jpg')->show();
            Thumb::create($file)->make('resize', array($width, $height))->rotate(array('degree', 180))->show();
            Thumb::create($file)->make('resize', array($width, $height))->reflection(array(40, 40, 80, true, '#a4a4a4'))->show();
            Thumb::create($file)->make('resize', array($width, $height))->save(base_path() . '/', 'aaa.jpg');
            Thumb::create($file)->make('resize', array($width, $height))->show();
        */

    });

^_^

Links