Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick works in command line but when exec() in php it returns 5 with "incompatible library version"

I'm having a bizarre problem with php 5.3.6 and ImageMagick (command line) using MAMP (and Macports too..I tried both) on OS X.

When I run the identify command from the CLI, it works fine. But when I run the exact same command using exec(), it returns a value code of 5 and in the apache error logs I have:

dyld: Library not loaded: /opt/local/lib/libfreetype.6.dylib
Referenced from: /opt/local/bin/identify Reason: Incompatible library version: identify requires version 14.0.0 or later, but libfreetype.6.dylib provides version 13.0.0

E.g. The cli command is: /opt/local/bin/identify /Users/leonardteo/Documents/1.jpg

This works just fine when executed from the command line. When executed from PHP:

exec("/opt/local/bin/identify /Users/leonardteo/Documents/1.jpg", $output, $return);

$return is 5

$output is nothing

Checking the apache logs gives the above issue with libfreetype.

I installed ImageMagick using Macports. I've also tried a manual build from source and running identify from /usr/local/bin/identify and I get the same result. I have also tried running PHP from Macports instead of MAMP and I get the same result.

Could someone please help shed light on this?

like image 426
Leonard Teo Avatar asked Oct 18 '11 19:10

Leonard Teo


1 Answers

Edit this file:

/Applications/MAMP/Library/bin/envvars

Comment out the following lines:

DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"

export DYLD_LIBRARY_PATH

like image 84
Leonard Teo Avatar answered Sep 23 '22 02:09

Leonard Teo