0

I need to make thumbnails of images in about 1000 directories. I'm using the library imagemagick.

async.each(files, function(file, cb) { if (fs.existsSync(process.env.UPLOAD_BASE_PATH + file + '/P.png')) { im.resize({ srcPath: process.env.UPLOAD_BASE_PATH + file + '/P.png', dstPath: process.env.UPLOAD_BASE_PATH + file + '/thumb.png', width: 225 }, function (err, stdout, stderr) { setTimeout(function () { console.log('File rezied: ' + process.env.UPLOAD_BASE_PATH + file + '/thumb.png'); cb(); //Done resizing image }, 100) }); } else { cb(); } }, function(err){ if (err){ console.log(err); res.send(400); } res.send(200); //All files resized }); 

It works but after a few hundred images I get: Error: spawn EAGAIN. It got something to do with number of processes running. Anything I can do about it? Most preferably in my node code.

2
  • Did you try increasing timeout values? May be it takes imagemagick to resize these a bit longer than what you gave. I am also wondering what would happen if it is not done asynchronously. Commented Jun 21, 2015 at 22:11
  • Another thread on here with possibly useful information: stackoverflow.com/questions/16222116/… Commented Jun 21, 2015 at 22:32

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.