Created
May 30, 2018 15:23
-
-
Save skelet00r/6c139ba4bcdc98386fb2d107539bf8b7 to your computer and use it in GitHub Desktop.
Create psd (nodejs - imagemagick)
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
const path = require('path'); | |
const fs = require('fs'); | |
const { exec } = require('child_process'); | |
let command = 'convert '; | |
const images = fs.readdirSync(path.resolve(__dirname, 'images')).filter(i => i.includes('jpg') || i.includes('jpeg')).map(i=> `images/${i}`) | |
command += images.map(i => { | |
const label = i.split('/')[1] | |
return `\\( -page +0+0 -label "${label}" ${i} -background none -mosaic -set colorspace RGB \\) ` | |
}).join('') | |
command += `\\( -clone 0--1 -background none -mosaic \\) -alpha Off -reverse "abc.psd"` | |
exec(command, { cwd: __dirname }, (error, stdout, stderr) => { | |
if (error) { | |
console.error(`exec error: ${error}`); | |
return; | |
} | |
console.log(`stdout: ${stdout}`); | |
console.log(`stderr: ${stderr}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment