Ganesh Kumar
Ganesh Kumar

Reputation: 1361

imagemagick error on node.js

I'm getting error like this

    node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Command failed: CreateProcessW: The system cannot find the file specified
.

    at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\imagemagic
k\imagemagick.js:64:15)
    at ChildProcess.emit (events.js:70:17)
    at maybeExit (child_process.js:361:16)
    at Socket.<anonymous> (child_process.js:466:7)
    at Socket.emit (events.js:67:17)
    at Array.0 (net.js:320:10)
    at EventEmitter._tickCallback (node.js:192:40)

image paths are fine & operations are on node v0.6.11 & Imagemagick v0.1.2

any idea abt problem

Upvotes: 1

Views: 4006

Answers (3)

muZk
muZk

Reputation: 3038

Maybe this reply helps someone else... I edited identify.path and convert.path and worked

var img = require('imagemagick');
im.identify.path = "C:/Program Files/ImageMagick-6.8.2-Q16/identify";
im.convert.path = "C:/Program Files/ImageMagick-6.8.2-Q16/convert";

I don't know if there are a more elegant solution.

Upvotes: 2

hotS85
hotS85

Reputation: 1036

Did you already isolate the error to a specific codeline?

If not, ok, we got little bit of information for debugging:

The system cannot find the file specified

You already may have a glitch where the problem could be, so go through all I/O operations and try to eliminate one by one. Debug with console.log or your favourite method to find your way through.

Upvotes: 0

Omar Al-Ithawi
Omar Al-Ithawi

Reputation: 5170

Make sure that ImageMagic is installed and available within the environment path. Try to use it from the commandline first, and do the operation yourself, not by using any other node modules.

If it works fine then you can use the child_process.exec() API like this:

var util = require('util'),
    exec = require('child_process').exec,
    child;

child = exec('cat *.js bad_file | wc -l',
  function (error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
      console.log('exec error: ' + error);
    }
});

For more information. Check this Process and Forking API in Node.JS.

One more thing. Don't forget to quote the paths that has spaces and special chars in them before passing them in the command line. This will save you lots of headache and bug hunting.

With the little information you provide this is all I can answer. That's why the answer is not exactly specific to your case. If you need more from this website (SO) you should at least provide enough code and even better complete (i.e. runnable) code that contains only the problematic part.

Upvotes: 1

Related Questions