views:

59

answers:

1

I have a PHP code block I've written that uses imagemagick's convert program (called through exec()) to create thumbnails of uploaded images (originally we tried using the PHP module calls, but kept running into memory errors).

Of course to do this I have to have the full path to convert, which varies from system to system (on my mac it's at /opt/local/bin/convert). I've been just looking it up on the server and setting it in a constant, but this is often less than ideal.

My question is, is there a way to programmatically lookup the install path of convert? I can then just store it in the database or something for quick lookup.

+1  A: 

If "convert" is in the include path for a user,

 $path = `which convert`;

should find it.

gnarf
Tried this before. It works when executed from the command line, but when run through apache the shell variables don't get set. $path returns null.
ChiperSoft