mirror of
https://github.com/smogon/sprites.git
synced 2026-08-20 00:34:22 -05:00
sheet: write montage filenames to stdin
This commit is contained in:
@@ -24,20 +24,28 @@ for (let i = 0; i < sheet.entries.length; i++) {
|
||||
}
|
||||
}
|
||||
|
||||
// Store list of sprite files in a temp file, Windows can't handle large cli arg
|
||||
// lists. Just append a random string to the dest file
|
||||
const tmpFile = `${dest}.tmp.${crypto.randomBytes(6).readUIntLE(0,6).toString(36)}`;
|
||||
fs.writeFileSync(tmpFile, sheet.entries.join("\n"), 'utf8');
|
||||
|
||||
cp.execFileSync("magick", [
|
||||
// Write list of filenames to stdin, Windows can't handle large cli arg lists.
|
||||
// Before we wrote a tmp file and deleted it afterwards, but apparently tup
|
||||
// can't track unlinkSync on Windows?
|
||||
const proc = cp.spawn("magick", [
|
||||
"montage",
|
||||
`@${tmpFile}`,
|
||||
"@-",
|
||||
"-background", "transparent",
|
||||
"-geometry", `${sheet.width}x${sheet.height}>`,
|
||||
"-gravity", "center",
|
||||
"-tile", `${sheet.tile}x`,
|
||||
"-depth", "8",
|
||||
dest
|
||||
]);
|
||||
], {
|
||||
stdio: ['pipe', 'inherit', 'inherit']
|
||||
});
|
||||
|
||||
fs.unlinkSync(tmpFile);
|
||||
// Write one at a time to avoid "malloc(): corrupted top size" error
|
||||
for (const entry of sheet.entries) {
|
||||
proc.stdin.write(entry + "\n");
|
||||
}
|
||||
proc.stdin.end();
|
||||
|
||||
proc.on('close', (code) => {
|
||||
process.exit(code);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user