Skip to content

arne-strout-icrossing/grunt-imagemagick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-imagemagick

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

Getting Started

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');

Documentation

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']
	  }
	}
});

Error Handling

Errors comming from the underlying cli are just displayed as default, you can get a warning thrown if you like by configuring a flag:

grunt.initConfig({
	"imagemagick-convert":{
	  dev:{
	    args:['test/resizeme.jpg','-resize', '25x25', 'test/resized/resizeme-small.jpg'],
	    fatals: true
	  }
	}
});

This is only working for

  • imagemagick-resize
  • imagemagick-convert

Tasks

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 :)

Contributing

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.

Release History

0.1.4 First functional build on NPM 0.1.5 Added documentation

License

Copyright (c) 2012 Arne Strout
Licensed under the MIT license.

About

Image Magick task for Grunt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •