Created
January 31, 2015 05:58
-
-
Save adamcoulombe/2930e1aaa3ce7f74bef9 to your computer and use it in GitHub Desktop.
generate pngs from all psds in a folder with grunt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
'convertPSD': { | |
target: { prop1:1 }, | |
options: { | |
defProperty: "defValue", | |
dFiles: { | |
cwd: './', | |
src: ['*.psd'], | |
dest: './' | |
} | |
} | |
} | |
}); | |
grunt.registerTask('default', 'convertPSD'); | |
grunt.registerMultiTask('convertPSD', 'Convert PSDs', function() { | |
var done = this.async(); | |
var curTask = this, | |
opts = curTask.options(); | |
if (!curTask.files.length && 'dFiles' in opts) { | |
var df = opts.dFiles; | |
curTask.files = grunt.file.expandMapping(df.src, df.dest , df); | |
} | |
this.files.forEach(function(file){ | |
console.log(file.src[0]) | |
var psdFile = file.src[0]; | |
grunt.util.spawn({ | |
cmd:'./ImageMagick/convert.exe', | |
args:[psdFile + '[0]', psdFile + '.png'] | |
}, function(error, result, code){ | |
console.log(error); | |
console.log(result); | |
console.log(code); | |
done(); | |
}) | |
}) | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment