Resizing images using imagemagick in node.js

In my application i tried to resize the image using imagemagick but i got following error error while resizing: imagesexecvp(): No such file or directory.this is my code

   im.resize({
  srcPath:  '/tmp/Images/' + req.files.image.name,
  dstPath: 'resized_'+req.files.image.name ,
  width:42,
  height:42
}, function(err, stdout, stderr){
  if (err) {

      console.log('error while resizing images' + stderr);
  };
});

The imagemagick module uses the convert and identify commands and the error you describe could happen because the commands can't be found. Make sure the commands are in a folder referenced by the path environment variable or, alternatively you can reference the commands in you node application:

var im = require('imagemagick');    
im.identify.path = '/opt/ImageMagick/bin/identify'
im.convert.path = '/opt/ImageMagick/bin/convert';

It looks like you are trying to resize the file without changing the destination. Try this:

im.resize({
  srcPath:  process.cwd() + '/tmp/Images/' + req.files.image.name,
  dstPath:  process.cwd() + '/tmp/Images/resized_'+req.files.image.name ,
  width:42,
  height:42
}, function(err, stdout, stderr){
  if (err) {
      console.log('error while resizing images' + stderr);
  };
  console.log( process.cwd() + '/tmp/Images/' + req.files.image.name + 'has been resized and saved as ' + process.cwd() + '/tmp/Images/resized_'+req.files.image.name)
});

You might also check your permissions (ls -l) in /tmp/Images/ to make sure they are set properly

You need to install image magic command line tools. Try brew install imagemagick

If you are on ubuntu, install package like this:

apt-get install imagemagick

After that, try again :D