Skip to content

Instantly share code, notes, and snippets.

@jiangli373
Created March 16, 2018 07:22
Show Gist options
  • Save jiangli373/e3943ea3303fb9d55c164fae10b8de25 to your computer and use it in GitHub Desktop.
Save jiangli373/e3943ea3303fb9d55c164fae10b8de25 to your computer and use it in GitHub Desktop.
gm转换psd到png
'use strict';
const fs = require('fs');
const gm = require('gm').subClass({imageMagick: true});
const instream = fs.createReadStream('./psd.psd');
const writeStream = fs.createWriteStream('./psd1.png');
gm(instream)
.flatten()
.stream('png', (err, stdout) => {
if (err) {
console.error(err);
return;
}
gm(stdout)
.compress('Zip')
.stream()
.pipe(writeStream);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment