Created
March 16, 2018 07:22
-
-
Save jiangli373/e3943ea3303fb9d55c164fae10b8de25 to your computer and use it in GitHub Desktop.
gm转换psd到png
This file contains hidden or 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
'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