Adds utility tasks for grunt to access ImageMagick via the node_imagemagick package. You will need to have image magick CLI tools installed as described in the node_imagemagick readme. see node-imagemagick
Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-imagemagick
Then add this line to your project's grunt.js
gruntfile:
grunt.loadNpmTasks('grunt-imagemagick');
Example Usage
grunt.initConfig({
"imagemagick-hisrc":{
dev:{
files:"**/*-2x.jpg",
suffix:["-2x","-1x","-low"],
}
},"imagemagick-resize":{
dev:{
from:'test/',
to:'test/resized/',
files:'resizeme.jpg',
props:{
width:100
}
}
},"imagemagick-convert":{
dev:{
args:['test/resizeme.jpg','-resize', '25x25', 'test/resized/resizeme-small.jpg']
}
}
});
imagemagick-convert Use the args property to identify the list of arguments to pass to ImageMagick's convert command.
imagemagick-resize The following properties are valid:
- from : The path where images will be pulled from.
- to : The output path for the resized images.
- files : The wildcard identifying the files to resize.
- props : The properties to pass to the node_imagemagick "resize" method. See node-imagemagick
imagemagick-hisrc This is a little utility task which runs over a set of image files and creates three sizes of each using a specified naming convention. This is great for auto-generating the three image sizes accepted by HiSRC. The following properties are valid:
- files : A wildcard identifying the files to resize, this should be a wildcard for the source image, which should be the full size retina image (2X)
- suffix : An array of suffixes to use. The first is the suffix for the large image, the second and third are the medium (normal) and small respectively. The assumption is that the source image follows the identified convention.
If you have any questions, feel free to ask, if you have any ideas, feel free to contribute a pull :)
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
0.1.4 First functional build on NPM 0.1.5 Added documentation
Copyright (c) 2012 Arne Strout
Licensed under the MIT license.