Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including grunt-imagemagick with all npm packages installed. Try it out:

var gruntImagemagick = require("grunt-imagemagick")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

grunt-imagemagick v0.1.5

Adds utility tasks for grunt which use ImageMagick

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

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.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free