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 imagemagick = require('imagemagick'); | |
const rootPath = require('app-root-path'); | |
const compositeImage = async (imageName, imageList) => new Promise((resolve, reject) => { | |
try { | |
const commands = [imageList[0]]; | |
for (let i = 1; i < imageList.length; i += 1) { | |
commands.push('-coalesce', 'null:', imageList[i], '-layers', 'composite'); | |
} | |
commands.push(`${rootPath}/images/${imageName}.png`); |
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 fs = require('fs'); | |
const rootPath = require('app-root-path'); | |
const composite = async () => { | |
const total = compositeInfo.length; | |
let current = 0; | |
for (const { background, hair, earrings, mouth, eyes, clothes } of compositeInfo) { | |
if (!fs.existsSync(`${rootPath}/images/${current}.png`)) { | |
const result = await compositeImage( | |
current, |
OlderNewer