Skip to content

Instantly share code, notes, and snippets.

@spacecowb0y
Created July 25, 2015 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spacecowb0y/5a21146a48a57da31132 to your computer and use it in GitHub Desktop.
Save spacecowb0y/5a21146a48a57da31132 to your computer and use it in GitHub Desktop.
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