Create psd (nodejs - imagemagick)
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