The following code throws an error:
const COUNT = 2528; // 2527 works, 2528 errors
const gm = require('gm').subClass({ imageMagick: true });
const brokenData = [];
for (let i = 0; i < COUNT; i++) {
brokenData.push([
Math.random() * 500, Math.random() * 500
]);
}
const tile = gm('./blank-tile.png')
.resize(500, 500)
.fill("red");
brokenData.forEach((point) => {
tile.drawCircle(point[0], point[1], point[0] + 4, point[1]);
});
tile.write(__dirname + '/test.png', (err) => {
if (err) {
throw err;
}
console.log('success');
});
As per the comment, it's fine when drawing 2527 circles, but throws the error at 2528 circles. It's the same every time, at least on my machine.
Here's the error:
Error: spawn E2BIG
at ChildProcess.spawn (internal/child_process.js:358:11)
at Object.spawn (child_process.js:533:9)
at spawn (/Users/callumacrae/Sites/testing-gm/node_modules/cross-spawn/index.js:17:18)
at gm._spawn (/Users/callumacrae/Sites/testing-gm/node_modules/gm/lib/command.js:224:14)
at /Users/callumacrae/Sites/testing-gm/node_modules/gm/lib/command.js:101:12
at series (/Users/callumacrae/Sites/testing-gm/node_modules/array-series/index.js:11:36)
at gm._preprocess (/Users/callumacrae/Sites/testing-gm/node_modules/gm/lib/command.js:177:5)
at gm.write (/Users/callumacrae/Sites/testing-gm/node_modules/gm/lib/command.js:99:10)
at Object.<anonymous> (/Users/callumacrae/Sites/testing-gm/test.js:21:6)
at Module._compile (internal/modules/cjs/loader.js:688:30)
I'm assuming it's coming from somewhere within gm, as I haven't provided any long argument lists!
The same thing happens whether I use imagemagick or graphicsmagick. Node version 10.13.0.
Any ideas?