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

巧了我就是萌 提交于 2019-12-21 09:31:58

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/7812299/imagemagick-works-in-command-line-but-when-exec-in-php-it-returns-5-with-inco

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!