Resize JPEG, PNG, WebP and TIFF images.
npm install grunt-sharp> Resize JPEG, PNG, WebP and TIFF images.
This plugin requires Grunt ~0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
``shell`
npm install grunt-sharp --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js`
grunt.loadNpmTasks('grunt-sharp');
This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that you upgrade, but in case you can't please use v0.3.2.
_Run this task with the grunt sharp command._
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
#### tasks
Type: Array
The list of tasks you want to run for an image. Each task is a set of transformations supported by sharp.
If you only want to apply a single set of transformations, you can obviate the tasks option and describe the transformations directly in the options object.
To transform all images in a folder using a single set of transformation:
`js`
sharp: {
rotated: {
files: [{
expand: true,
cwd: 'src/images/',
src: ['*/.png'],
dest: 'build/images/'
}],
options: {
background: 'white',
flatten: true,
resize: [48, 48],
rotate: 180
}
}
}
To apply multiple sets of transformations:
`js`
sharp: {
apple: {
files: [{
expand: true,
cwd: 'src/images/',
src: 'icon.png',
dest: 'build/images/'
}],
options: {
tasks: [
{resize: 64, rename: '{base}-32x32@2x.{ext}'},
{resize: 32, rename: '{base}-32x32.{ext}'},
{resize: 32, rename: '{base}-16x16@2x.{ext}'},
{resize: 16, rename: '{base}-16x16.{ext}'}
]
}
}
}
This task supports all the file mapping format Grunt supports. Please read Globbing patterns and Building the files object dynamically for additional details.
* Code: git clone git://github.com/unindented/grunt-sharp.git`
* Home:
* Daniel Perez Alvarez (unindented@gmail.com)
Copyright (c) 2015 Daniel Perez Alvarez (unindented.org). This is free software, and may be redistributed under the terms specified in the LICENSE file.