sudo convert .... fails, on OSX, but convert is OK

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
garygriswold

sudo convert .... fails, on OSX, but convert is OK

Post by garygriswold »

Hello,

When I enter a convert command with sudo, it fails with the following errors:
dyld: Library not loaded: /ImageMagick-6.5.8/lib/libMagickCore.2.dylib
Referenced from: /usr/bin/convert
Reason: image not found

A library does exist at /usr/local/ImageMagick-6.5.8/lib/libMagickCore.2.dylib
and $DYLD_LIBRARY_PATH points at this lib directory.

Also, if I do a convert without sudo, it works fine. And sudo works fine for all other uses.

I am using Mac OS X 10.6 (Snow Leopard). ImageMagic-6.5.8 was installed from the binary at http://www.imagemagick.org/script/binar ... php#macosx

The initial problem was that convert did not work when being called from a php shell_exec('convert ...') command. I suspected it was a problem, because php is running as user _www and my profile is not executed. However, while investigating that problem, I discovered that sudo did not work, and that I think is a bug.

Any help would be greatly appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sudo convert .... fails, on OSX, but convert is OK

Post by fmw42 »

php will need the full path to convert to run the exec command.

sudo should not be needed when running in command line.

So you need to find the path to convert, which is usually (if manually installed) in /usr/local/bin or /usr/bin. If you used MacPorts or FINK, then it will be in a special directory where they put everything.

Try

<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>

or at the command line

find /usr | grep "convert"

or

sudo find / | grep "convert"
Post Reply