Fanning Software Consulting

Locating ImageMagick on a Macintosh Computer

QUESTION: I have installed ImageMagick on my computer but the Coyote Graphics commands can't seem to find it. What do I need to do make it available to them?

ANSWER: The Coyote Graphics routines look for ImageMagick by spawning the ImageMagick convert command inside the Coyote Library function, cgHasImageMagick. If the command is not found an error is generated and cgHasImageMagick returns a 0. If no error is generated, the function returns a 1.

This means, in general, that the shell running IDL must have its PATH environment variable set to include the path to the ImageMagick convert command. Otherwise, ImageMagick will not be found, even if it is installed. On Windows and UNIX machines the path is typically set up properly when ImageMagick is installed. The Macintosh computer is a special case, however, and requires a different procedure.

I don't have a Macintosh computer to test on, so I am flying a little bit blind here. This is what I have been told by people who have figured out what needs to be done. If you have a better idea or explanation, I am more than happy to hear it.

Here is how I understand the problem. On most UNIX systems, a shell is spawned to start a process. The shell has its own environment variables. This apparently only happens on Macintosh computers if a program is run from the command line. If the program is run as an application (*.app), then the environment variables are determined by an XML file called environment.plist.

If ImageMagick is installed via MacPorts, then the convert command lives in /opt/local/bin/. It is this directory that needs to get on the PATH environment variable. Users have solved this problem in a couple of ways.

After restarting IDL, you can test to see if your path is set propertly by running cgHasImageMagick. If it returns 1, it has found ImageMagick. It will return a 0 if ImageMagick cannot be found.

   IDL> Print, cgHasImageMagick()
        1

In IDL 8.x it is possible that even if you install ImageMagick correctly, you will still have trouble spawning an ImageMagick command. The solution to this problem can be found in this article.

Version of IDL used to prepare this article: IDL 7.0.1.

Last Updated: 11 March 2011