Skip to content

Instantly share code, notes, and snippets.

View 6londe's full-sized avatar

Changhoon Lee 6londe

View GitHub Profile
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`);
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,