laravel-elixir-image-resize
Version:
Laravel Elixir 3 wrapper around gulp-image-resize Gulp task.
89 lines (55 loc) • 2.65 kB
Markdown
# laravel-elixir-image-resize
> This is a simple [image-resize](https://github.com/scalableminds/gulp-image-resize) wrapper around [Laravel Elixir 3](https://github.com/laravel/elixir). Add it to your Elixir-enhanced Gulpfile, like so:
## Install
Install with [npm](https://npmjs.org/package/laravel-elixir-image-resize)
```
npm install --save-dev laravel-elixir-image-resize
```
_For Elixir 2.* compatibility, install version 0.3.1_
```
npm install --save-dev laravel-elixir-image-resize@0.3.1
```
### Requires GraphicsMagick or ImageMagick
Make sure GraphicsMagick or ImageMagick is installed on your system and properly set up in your `PATH`.
See [gulp-image-resize](https://github.com/scalableminds/gulp-image-resize#install) installation instructions for your favorite operating system
## Usage
### Example Resize *Gulpfile*:
```javascript
var elixir = require('laravel-elixir');
require('laravel-elixir-image-resize');
elixir(function(mix) {
mix.imageresize({ width:1200, height:750 });
});
```
This will resize all image files in `resources/assets/images` to the specified `width` and `height` and write the output to the default `public/images` folder. All arguments supported by [gulp-image-resize](https://github.com/scalableminds/gulp-image-resize#api) apply.
### Example with Resize and Rename:
```javascript
mix.imageresize({ width:1200, height:750 }, { suffix: '-lg'});
```
This will resize all image files in `resources/assets/images` and add the suffix `-lg` to the resized filename. All arguments supported by [gulp-rename](https://github.com/hparra/gulp-rename#notes) apply.
### Examples with different source folder:
```javascript
//resize, reformat & add suffix using a specific file
mix.imageresize({ width:1200, height:750 }, { suffix: '-lg'}, './resources/assets/img/banner.png');
//resize, reformat & add suffix using files from alternate folder
mix.imageresize({ width:1200, height:750, format:'png' }, { suffix: '-lg'}, './resources/assets/img');
//resize, reformat, but no rename using files from alternate folder
mix.imageresize({ width:1200, height:750 }, null, './resources/assets/img');
```
### Examples with different output folder:
```javascript
mix.imageresize({ width:1200, height:750 }, { suffix: '-lg'}, './resources/assets/img', 'public/img');
```
### Change Default Image Directory
Change the default image directory in elixir config. Do that in your *Gulpfile* like so:
```javascript
elixir.config.imagePath = 'own-image-folder';
```
or in elixir.json:
```javascript
{
"imagePath": "your-img-folder"
}
```
### License
[MIT license](http://opensource.org/licenses/MIT)