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.

Joe
  • 4,274
  • 32
  • 95
  • 175
  • 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. – Alp Jun 21 '15 at 22:11
  • Another thread on here with possibly useful information: http://stackoverflow.com/questions/16222116/error-spawn-enoent-while-using-gm-in-node – Michael Blankenship Jun 21 '15 at 22:32

0 Answers0