Saturday, February 16, 2008
Getting Imagemagick (and more) to work with MAMP on OS X
Posted by Bryan Rite in Technology, Tutorial
29 Comments
I’ve been using MAMP on my macbook for doing my web development at home and can’t say enough good things about it. Unfortunately I had to start using some binaries not included with MAMP, ImageMagick for example.
Update: Commentors have been reporting this fix is not working on Snow Leopard or MAMP 1.8.4
Installing ImageMagick via MacPorts is simple enough:
sudo port install ImageMagick
but trying to run it via the MAMP stack gives you the apache error:
dyld: Symbol not found: __cg_jpeg_resync_to_restart Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO Expected in: /Applications/MAMP/Library/lib/libjpeg.62.dylib
or something similar. I was able to get it to go, but you need to break the sandbox, so it may not be a viable solution for everyone.
Once ImageMagick is installed, head to:
/Applications/MAMP/Library/bin/envvars
Here we want to comment out the two lines:
#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH" #export DYLD_LIBRARY_PATH
and add the line:
export PATH="$PATH:/opt/local/bin"
What we’re doing is using our systems default DYLD Library path, not the sandboxed one, and exporting our MacPorts bin directory into the sandbox PATH, so it can execute your ImageMagick bins like convert without specifying the full path to it.
Presto! I’m not sure of the full consequences of doing this but I haven’t run into any problems yet and nothing seems to break as a result. Always backup the original files tho!
29 Responses to “Getting Imagemagick (and more) to work with MAMP on OS X”
Trackbacks & Pingbacks:
-
-
[...] Wie man ImageMagick in MAMP bzw. MAMP PRO unter OS X zum laufen bekommt beschreibt Bryan Rite in seinem Beitrag Getting Imagemagick (and more) to work with MAMP on OS X. [...]
Wow, thanks. I just spent a lot of time looking for a way to use ImageMagick with MAMP. Nothing seemed to work until this.
Of course, I don’t understand this much, so if it takes everything else down, I’ll be bummed, but c’est la guerre.
Thank you! Thank you! Thank you! You’re lucky you’re not within reach or I’d give you a big sloppy kiss right now. I’ve been struggling with ImageMagick and MAMP for days, and I’m on a tight schedule. This post just totally saved my sanity…
I have to go update a whole slew of forum posts now…
Hey I also use MAMP but not with ImageMagick but at least now I know how to use it
MAMP is awesome tho, I even prefer developing on my Mac now instead of on my PC with some other PHP/MySQL dev server.
I’ve also tried some things to get this going but nothing really worked until I read your hints. So thanks for that.
You rock Bryan! I even KNEW that the problem was that MAMP wasn’t looking in the right place (via the Console) but I had no idea what to fix! I spent several hours pouring through all the http config files. If it weren’t for you, I probably wouldn’t sleep tonight! Ah, I can’t wait for those extra Z’s.
Actually, in all seriousness, do you have a Paypal account? I got paid for the work I’m doing on this matter and you totally deserve a $10 tip for this note. Send me an email and let me know if I can send you some dosh!
Also of note, to anyone else out there: if you’re like me and installed Imagemagick and MAMP in order to get tex to show equations, you’ll also need to make sure that gs can run under httpd and for that you’ll need to make sure that MAMP has usr/local/bin. So just add on to Bryan’s path like so:
export PATH=”$PATH:/opt/local/bin:/usr/local/bin”
I thought this solution was going to save me a ton of time. However, it doesn’t work for me. I’m getting:
Can’t locate Image/Magick.pm in @INC
I’ve made the changes exactly as advised and double checked envvars with vi to make sure no hidden characters were in there. Nothing seems to work. Could it be my shebang?
#!/usr/bin/perl -w
Could it be my MAMP version? 1.7.2
I’ve even reloaded ImageMagick from the cpan prompt. It works fine through the shell and on my web server, just not through MAMP. What am I doing wrong? And, yes, I did restart MAMP after making the envvars edit.
Okay, figured it out. #!/opt/local/bin/perl did the trick!!
Thanks and good luck w/ Charlotte?
Thanks. Exactly what I needed!
I found a dulled down solution to this that uses an installer for all those lazy people out there — like me: http://forum.webedition.de/phpBB/viewtopic.php?f=2&t=3534
Dude.
You’re a lifesaver.
Cheers.
You are a blessed soul, sir.
MAMP can be a bit overzealous sometimes, can it not?
THANKS! This is the solution to get sips commands working with MAMP as well.
Wow, thanks. I just spent a lot of time looking for a way to use ImageMagick with MAMP. Nothing seemed to work until this.
have to go update a whole slew of forum posts now
I have no clue about using terminal and just followed instructions… Does anybody know why I got the errors here below when I tried to install ImageMagick?
I just installed the MacPorts and ran a selfupdate, so I suppose they are fine.
Error: Target org.macports.build returned: shell command ” cd “/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_archivers_bzip2/work/bzip2-1.0.5″ && make all PREFIX=”/opt/local” ” returned error 127
Command output: sh: line 1: make: command not found
Error: The following dependencies failed to build: bzip2 expat fontconfig freetype zlib libiconv gperf jpeg libpng libxml2 pkgconfig tiff xorg-libXext xorg-libX11 xorg-bigreqsproto xorg-inputproto xorg-kbproto xorg-libXau xorg-xproto xorg-libXdmcp xorg-xcmiscproto xorg-xextproto xorg-xf86bigfontproto xorg-xtrans xorg-libXt autoconf help2man gettext ncurses ncursesw p5-locale-gettext perl5 perl5.8 m4 automake libtool xorg-libsm xorg-libice xorg-util-macros
Error: Status 1 encountered during processing.
Thank you for your help in advance!
Looks like you don’t have
makeinstalled on your computer. Double check that you installed Xcode on your machine, it is a pre-req for MacPorts:http://www.macports.org/install.php
Here is a complete french tutorial for ImageMagick, Mamp, Imagick classe, etc
http://eddy.martignier.ch/?p=13
Based on this tutorial.. Thx to BryBot!
Thanks very much for your solution. Alternatively you can change the references to DYLD_LIBRARY_PATH to DYLD_FALLBACK_LIBRARY_PATH. The problem seems to be that the MAMP version of the library is masking the correct system version. Using DYLD_FALLBACK_LIBRARY_PATH prevents this, as the operating system will only look in these paths once it has looked through the system libraries.
diddo! thanks a ton!
Yeah!!!! Thanks!!!!
I can’t seem to get this working in Snow Leopard, and the new MAMP 1.8.3 anyone get it working? or is there new instructions
I’m also having issues installing ImageMagick on OS X 10.6.2 with MAMP 1.8.4
I know the issue is related to MAMP running in 32-bit universal mode and ImageMagick being built in 64-bit when you use “sudo port install ImageMagick”. To overcome this, I’ve edited /opt/local/etc/macports/variants.conf and added “+universal” to the last line of the file. This causes universal compilations to take place. So I know my dynamic libraries are universal.
Problem is, all my make builds are still defaulting to 64-bit. So when I check imagick.so, it still shows up as “imagick.so: Mach-O 64-bit bundle x86_64″
This causes my PHP log to show:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/imagick.so’ – (null) in Unknown on line 0
So I know MAMP cannot load the .so file because it is incompatible. I’m still trying to compile in universal mode, but running into way too many road blocks.
Anyone got any pointers?
Thank you.
For weeks I’ve been searching (off and on) for this answer. I have waded through reams of posts.
When I read this one, I thought, “BS, it’s too simple.”
ImageMagick now works on my local (mac) server. If you had a ‘donate’ button, I’d contribute.
It IS simple if you have Leopard or lower. This fails with Snow Leopard.
See this site:
http://unrealexpectations.com/blog/2010/01/mamp-imagick-on-snow-leopard/
I’ve been unsuccessful with it though. Maybe you’ll be luckier.
The recommended solution did not work for me. The only way that I could get IM to work was to put /opt/local/lib at the front of DYLD_LIBRARY_PATH.. but then, Apache would not launch properly in MAMP (and no error in the log… so it’s a MAMP thing).
This worked for me:
if(stristr($_SERVER['SERVER_NAME'],’localhost’) !== FALSE)
{
putenv(‘DYLD_LIBRARY_PATH=”/opt/local/lib”‘);
}
Just before the call to IM. I did not need to make any changes to envars. The solution that worked for me relies on safe_mode being off.
Hope this helps someone.
=dave=