Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (41 sloc) 2.13 KB


Simple image resizing bundle for Laravel PHP framework.

This bundle will allow you to resize an uploaded image or any image from the file system with ease. Supported image types are: JPG/JPEG, PNG, GIF.


Install Resizer using artisan:

php artisan bundle:install resizer

Then in your application/bundles.php file, add the following line to load Resizer automatically:

return array(
    'resizer' => array( 'auto' => true )

Or without the 'auto' => true to load it on demand:

return array(


In your view files, you'd add a file input element.

<?php Input::file('picture') ?>

In your routes.php file or in any of your controller files, you can start the Resizer bundle if you haven't set it to auto-load by calling:


Then you can start resizing your images by simply calling:

Resizer::open( mixed $file )
    ->resize( int $width , int $height , string 'exact, portrait, landscape, fit, auto or crop' )
    ->save( string 'path/to/file.jpg' , int $quality );


Route::post('image/update', function() {
    $img = Input::file('picture');
    // Save a thumbnail
    $success = Resizer::open( $img )
        ->resize( 200 , 200 , 'crop' )
        ->save( 'images/my-new-filename.jpg' , 90 );
    if ( $success ) {
        return 'woohoo';
    } else {
        return 'lame';


Options have been added to allow for choosing where to crop from. You can set the vertical and horizontal crop positions in the /config/defaults.php file. Better yet, copy that file into your /application/config/ directory and rename it to resizer.php, so that when updating the bundle, your configuration isn't reset.


The image resize class was originally written in a tutorial by Jarrod Oberto on NetTuts+. I only modified it to use Laravel's File class, updated the coding style, added comments throughout the class file and turned it into a Laravel bundle.