Learn me some ImageMagick
June 15, 2013 12:30 PM   Subscribe

I have MAMP on Mac OS Lion. I want to install the ImageMagick extension. I am trying to use these instructions, but am running into problems.

It sounds like the easiest way to start is to install MacPorts, so I did that. I also have the latest version of Xcode and installed the Command Line Tools. When I get to the "pecl install imagick" part, it can't find PECL. This is the part I am stuck at.

I am pretty computer literate (web/game designer) but I have no experience with Terminal, so this command line stuff has me flummuxed. Help?
posted by oulipian to Computers & Internet (21 answers total) 1 user marked this as a favorite
Did you do the first part (this appears to be part 2) where he install PECL?

"In Part 1 of my MAMP + Lion series, I set up my MAMP installation so that I could use the included PECL installer."

If so, possibly you just need to add pecl to your path.
posted by RustyBrooks at 12:54 PM on June 15, 2013

Best answer: With MacPorts, you would do something like the following to look for the base ImageMagick:
$ sudo port search imagemagick
To install:
$ sudo port install imagemagick
After installing the Perl and PHP base components that you need, there are Perl and PHP components you can install to complete your MAMP stack:
$ sudo port install p5-perlmagick
$ sudo port install php-imagick

posted by Blazecock Pileon at 12:55 PM on June 15, 2013

Maybe this will help?
posted by destructive cactus at 12:55 PM on June 15, 2013

Response by poster: Okay, I think I managed to install the MAMP Components.

I'm having trouble following the instructions because I don't know what things like "add pecl to your path" mean. If I type any of the things Blazecock posted into Terminal I just get an error.
posted by oulipian at 1:27 PM on June 15, 2013

What error do you get?
posted by Blazecock Pileon at 1:41 PM on June 15, 2013

The nice thing about MacPorts is that you generally don't have to add directories to your environment's path, or even know what that means. If you have a working MacPorts setup, then knowing what the error messages are would help with troubleshooting.
posted by Blazecock Pileon at 1:43 PM on June 15, 2013

Response by poster: "sudo: port: command not found"
posted by oulipian at 2:00 PM on June 15, 2013

Best answer: "port: command not found" means you don't have MacPorts installed correctly.

Follow the MacPorts instructions, then quit and restart terminal and try again.
posted by toxic at 2:07 PM on June 15, 2013 [1 favorite]

Response by poster: Okay, I reinstalled MacPorts and then ran sudo port install imagemagick, and this happened:

"Error: org.macports.activate for port python27 returned: Image error: /Applications/MacPorts/Python 2.7/Build Applet.app/Contents/Info.plist already exists and does not belong to a registered port. Unable to activate port python27. Use 'port -f activate python27' to force the activation.
Error: Failed to install python27
Please see the log file for port python27 for details:
Error: The following dependencies were not installed: ghostscript xorg-libXext xorg-libX11 xorg-libxcb python27 xorg-libpthread-stubs xorg-xcb-proto libxml2 xorg-xextproto xorg-libXt xorg-libsm xorg-libice urw-fonts webp
To report a bug, follow the instructions in the guide:
Error: Processing of port imagemagick failed"
posted by oulipian at 2:22 PM on June 15, 2013

In a Terminal window, type:
$ sudo port -f activate python27
This helps make the installation of Python version 2.7 the one that is used to build components dependent on that specific version of Python. For example, after activating this version of Python, you can type the following to confirm which version of Python you're now running:
$ python -V
As a larger point, if you ever start writing Python scripts, this is useful way to test them under different versions of Python, where features can come and go or behave in different ways.
posted by Blazecock Pileon at 2:34 PM on June 15, 2013

Response by poster: Okay! I did all that, and then I ran "sudo port install php-imagick" and it worked with no errors. Then I did the final "cp" command in the initial instructions I linked to, and restarted Apache. But it's still not working. When I run phpinfo I get this PHP error: "Unable to load dynamic library '/Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/imagick.so' - dlopen(/Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/imagick.so, 9): image not found in Unknown on line 0"
posted by oulipian at 2:51 PM on June 15, 2013

What happens if you type:
$ ls -al /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/imagick.so

posted by Blazecock Pileon at 2:52 PM on June 15, 2013

Response by poster: "No such file or directory"
posted by oulipian at 2:54 PM on June 15, 2013

Response by poster: There's a file called "imagick.so" in /opt/local/lib/php54/extensions/no-debug-non-zts-20100525. Is it in the wrong place?
posted by oulipian at 2:56 PM on June 15, 2013

Best answer: If you're going with the MAMP installer, try reinstalling that. Otherwise, you'll need to start making directories and doing some linking, e.g.:
$ find /opt -name imagick.so
... (location of MacPorts' imagick.so file)
$ mkdir -p /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525
$ ln -s *foo* /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/imagick.so
Where *foo* is where find says the file
is located.

On preview, you might do the following:
$ mkdir -p /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525
$ ln -s /opt/local/lib/php54/extensions/no-debug-non-zts-20100525/imagick.so /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/imagick.so

posted by Blazecock Pileon at 2:59 PM on June 15, 2013

Usually, this sort of thing can lead to mixing of libraries and versions of libraries, which rarely ends well.

It looks like the minor versions of PHP line up in your case (v5.4) but this is something to look out for — the MAMP package probably doesn't know about what MacPorts packages are doing — how they are compiled and where they are installed to — and vice versa.

If you mix these two sources, you may have some customization or clean-up to do. Try to stick to one or as few sources of packages for your development process, if you can. Saves on the hassle.
posted by Blazecock Pileon at 3:06 PM on June 15, 2013

Response by poster: Okay! ImageMagick is installed, and I updated the library, and it's definitely working. Thanks for all your help, Blazecock! What a weird, complicated process.

Unfortunately, I'm running into another issue now. I'm using ImageMagick as part of WordPress, so it can auto-generate thumbnails and such, and it's generating images that are slightly the wrong dimensions. WordPress is generating a file called "Image-138x85" that is actually 137 x 85 pixels. There are no PHP errors and I have no idea how to fix it. It seems to be this same issue, which was supposedly fixed already. What a nightmare.
posted by oulipian at 3:44 PM on June 15, 2013

Response by poster: Okay, found a fix for the WordPress plugin here. I think everything is working now. Whew!
posted by oulipian at 3:55 PM on June 15, 2013

FYI, you might want to check out the homebrew project if you plan on installing other things like this on the future. It's like Mac Ports, but written in Ruby and much much much more intelligent/intuitive/helpful.

Sounds like you've got everything working now, so maybe this advice isn't really for you necessarily. Just thought I'd throw it out there.
posted by oceanjesse at 6:42 PM on June 15, 2013

Meh, homebrew breaks for me on a regular basis. I gave it up and went back to macports.
posted by RustyBrooks at 6:44 PM on June 15, 2013 [1 favorite]

Response by poster: Any advice is appreciated, thanks. I'd like to have more of a working knowledge of this stuff.
posted by oulipian at 7:25 PM on June 15, 2013

« Older Where can I find P.T. Barnum's will?   |   The Parallel Bars in The Castle Newer »
This thread is closed to new comments.