2017 © Pedro Peláez
 

library upstream

A simple composer package for Laravel 5 that assists in file uploads and image resizing/cropping.

image

aquanode/upstream

A simple composer package for Laravel 5 that assists in file uploads and image resizing/cropping.

  • Tuesday, April 21, 2015
  • by Aquanode
  • Repository
  • 0 Watchers
  • 0 Stars
  • 119 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Upstream

A simple composer package for Laravel 5 that assists in file uploads and image resizing/cropping., (*1)

, (*2)

Installation

To install Upstream, make sure regulus/upstream has been added to Laravel 5's composer.json file., (*3)

"require": {
    "regulus/upstream": "0.6.*"
},

Then run php composer.phar update from the command line. Composer will install the Upstream package. Now, all you have to do is register the service provider and set up Upstream's alias in config/app.php. Add this to the providers array:, (*4)

Regulus\Upstream\UpstreamServiceProvider::class,

And add this to the aliases array:, (*5)

'Upstream' => Regulus\Upstream\Facade::class,

Finally, run php artisan vendor:publish to publish the config file and language file., (*6)

, (*7)

Uploading Files

$config = [
    'path'            => 'uploads/pdfs', // the path to upload to
    'field'           => 'file',         // name of field (use "fields" for an array with multiple fields)
    'filename'        => 'temp',         // the basename of the file (extension will be added automatically)
    'fileTypes'       => ['png', 'jpg'], // the file types to allow
    'createDirectory' => true,           // automatically creates directory if it doesn't exist
    'overwrite'       => true,           // whether or not to overwrite existing file of the same name
    'maxFileSize'     => '5MB',          // the maximum filesize of file to be uploaded
];

$upstream = Upstream::make($config);
$result   = $upstream->upload();

Note: Special filename strings are available including [LOWERCASE], [UNDERSCORED], [LOWERCASE-UNDERSCORED], [DASHED], [LOWERCASE-DASHED], and [RANDOM]. The former five are used to make formatting adjustments to the original filename. The latter can be used to set the filename to a random string (along with its original extension)., (*8)

, (*9)

Resizing Images and Creating Thumbnails

$config = [
    'path'               => 'uploads/images',
    'fields'             => ['picture', 'picture2'],
    'filename'           => 'temp',
    'fileTypes'          => 'images',
    'createDirectory'    => true,
    'overwrite'          => true,
    'maxFileSize'        => '5MB',
    'imageResize'        => true,
    'imageResizeQuality' => 60,
    'imageCrop'          => true,
    'imageDimensions'    => [
        'w'  => 720, // image width
        'h'  => 360, // image height
        'tw' => 180, // thumbnail image width
        'th' => 180, // thumbnail image height
    ],
];

$upstream = Upstream::make($config);
$result   = $upstream->upload();

An entire set of configuration array is available in the config file at src/config/config.php. You may crop images after they have been uploaded with the following:, (*10)

$config = [
    'path'            => 'uploads/images',
    'filename'        => 'temp-'.$id.'.jpg',
    'newFilename'     => $id.'.jpg',
    'createDirectory' => true,
    'overwrite'       => true,
    'imageThumb'      => true,
    'imageDimensions' => [
        'w'  => 260, // image width
        'h'  => 260, // image height
        'tw' => 120, // thumbnail image width
        'th' => 120, // thumbnail image height
    ],
    'cropPosition' => [
        'x' => $input['x'],      // X position
        'y' => $input['y'],      // Y position
        'w' => $input['width'],  // width of cropped area
        'h' => $input['height'], // height of cropped area
    ],
];

$result = Upstream::cropImage($config);

You may use a JavaScript image cropper such as Cropper to set the cropPosition. If you leave cropPosition null or unset, the image will first be scaled to 140% of the target dimensions and then cropped from the center., (*11)

The Versions

21/04 2015

dev-master

9999999-dev

A simple composer package for Laravel 5 that assists in file uploads and image resizing/cropping.

  Sources   Download

MIT

The Requires

 

by Cody Jassman

19/04 2015

v0.5.0

0.5.0.0

A simple composer package for Laravel 5 that assists in file uploads and image resizing/cropping.

  Sources   Download

MIT

The Requires

 

by Cody Jassman

06/03 2015

v0.4.5

0.4.5.0

A simple composer package that assists in file uploads and image resizing/cropping.

  Sources   Download

MIT

The Requires

 

by Cody Jassman

27/11 2014

v0.4.4

0.4.4.0

A simple composer package that assists in file uploads and image resizing/cropping.

  Sources   Download

MIT

The Requires

 

by Cody Jassman

26/07 2014

v0.4.0

0.4.0.0

A simple composer package that assists in file uploads and image resizing/cropping. Works great with jCrop and jquery-file-upload.

  Sources   Download

MIT

The Requires

 

by Cody Jassman