Created
July 25, 2015 00:30
-
-
Save spacecowb0y/5a21146a48a57da31132 to your computer and use it in GitHub Desktop.
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
var through = require('through2'); | |
var gutil = require('gulp-util'); | |
var PluginError = gutil.PluginError; | |
var PSD = require('psd'); | |
function NoopPlugin(file, encoding, callback) { | |
if (file.isNull() || file.isDirectory()) { | |
this.push(file); | |
return callback(); | |
} | |
if (file.isStream()) { | |
this.emit('error', new PluginError({ | |
plugin: 'PSD', | |
message: 'Streams are not supported.' | |
})); | |
return callback(); | |
} | |
if (file.isBuffer()) { | |
PSD.open(file.path).then(function (psd) { | |
return psd.image.saveAsPng('./tmp/output.png'); | |
}); | |
this.push(file); | |
return callback(); | |
} | |
}; | |
function gulpPSD(){ | |
return through.obj(NoopPlugin); | |
} | |
module.exports = gulpPSD; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment