Skip to content

Instantly share code, notes, and snippets.

@6londe
Created September 4, 2022 12:04
Show Gist options
  • Save 6londe/c3656a45ac15889a6fdaf54086470555 to your computer and use it in GitHub Desktop.
Save 6londe/c3656a45ac15889a6fdaf54086470555 to your computer and use it in GitHub Desktop.
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,
[
`${rootPath}/background/${background}`,
`${rootPath}/face/default_face.png`,
`${rootPath}/hair/${hair}`,
`${rootPath}/earrings/${earrings}`,
`${rootPath}/mouth/${mouth}`,
`${rootPath}/eyes/${eyes}`,
`${rootPath}/clothes/${clothes}`,
],
);
console.log(`[${current + 1}/${total}] ${result}`);
}
current += 1;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment