Skip to content

Instantly share code, notes, and snippets.

@adammiller
Created January 17, 2013 19:39
Show Gist options
  • Save adammiller/4558972 to your computer and use it in GitHub Desktop.
Save adammiller/4558972 to your computer and use it in GitHub Desktop.
// Build and update staging
grunt.registerTask("sprite", "Builds sprite sheets from the src imges", function() {
var task = this,
// tell grunt this task is async
done = this.async(),
commands = [
"montage img/_icons_blue/*.png -tile 1x -geometry '100x80>+0+0' -gravity NorthWest -background transparent img/icon_blue_sprite_2x.png",
"montage img/_icons_white/*.png -tile 1x -geometry '100x80>+0+0' -gravity NorthWest -background transparent img/icon_white_sprite_2x.png",
"convert img/icon_white_sprite_2x.png -negate img/icon_black_sprite_2x.png",
"convert img/icon_white_sprite_2x.png -resize 50% img/icon_white_sprite_1x.png",
"convert img/icon_black_sprite_2x.png -resize 50% img/icon_black_sprite_1x.png",
"convert img/icon_blue_sprite_2x.png -resize 50% img/icon_blue_sprite_1x.png"
];
var child = exec( commands.join( " && " ) ,
function (error, stdout, stderr) {
console.log('Sprite generation complete. Please update the CSS and documentation accordingly');
if (error !== null) {
console.log('exec error: ' + error);
// Execute the callback when the async task is done
done();
}
});
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment