0

I'm trying to use imagemagick's "identify" from node.js, but it's not working. I have installed imagemagick using

brew install imagemagick

and it's in /usr/local/bin/identify etc.

I have created a script to start my server like this:

#!/bin/bash
echo "imagemagick: `which identify`"
/Users/myname/.nvm/v0.6.10/bin/node /path/to/server.js -g /some/directory/argument -port 8475

When I run the script from Terminal (Mac OS X 10.7), the output is as follows:

imagemagick: /usr/local/bin/identify
[... output from node.js comes here ...]

However, later on the script complains that identify could not be found. Make sure you have it installed and in your path etc.

The node.js imagemagick module calls childproc.spawn('identify', args);.

How can I make node.js use the same PATH as the bash script?

basteln
  • 2,483
  • 2
  • 19
  • 20
  • 1
    `spawn()` can find all executables in my $PATH just fine, but I notice you're using an old Node (0.6) and I only tested with 0.8 and 0.10. You could set the path explicitely, see [this part of node-imagemagic](https://github.com/rsms/node-imagemagick/blob/master/imagemagick.js#L178). Also, [spawn supports passing environment variables](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options), but I don't know if Node 0.6 supported that. – robertklep Mar 23 '13 at 13:40
  • I changed the line in node-imagemagick to `exports.identify.path = '/usr/local/bin/identify';` but it still can't find it...I think the error has to be somewhere else. I'll have a look around. – basteln Mar 23 '13 at 13:50
  • 1
    FWIW, you don't have to change the node-imagemagick code, `var im = require('imagemagick'); im.identify.path = '...'` would have sufficed (because it's exported) :) – robertklep Mar 23 '13 at 13:55

0 Answers0