Blog

Or search support forum

What's Global Moxie?

Global Moxie is the hypertext laboratory of Josh Clark, whose projects include the Big Medium web content management system. Josh creates web applications and websites from his multimedia studio in Paris, France.

What's Big Medium?

Big Medium is flexible, easy-to-use server software for creating and editing websites directly from your browser. Check out the features or download now.

Moxiemail

Enter your e-mail to receive occasional updates:

Installing ImageMagick on OSX

Posted Dec 8, 2006 (updated Jun 14, 2007)

I installed ImageMagick on a Mac OSX server this week and figured I'd share the necessary steps and details here. (Hey Mac-based developers and designers, these instructions will also work for installing ImageMagick on your personal Mac, too.)

What's ImageMagick?

ImageMagick is a code library that can do loads of different operations and transformations on image files. Most folks use ImageMagick only indirectly; it's commonly used as a utility by other programs. Big Medium uses it for resizing images, as do a host of other applications and image galleries.

Let's get after it

I used the following steps to install ImageMagick on OSX Tiger (10.4.8). To make things easier, we'll use MacPorts (formerly called DarwinPorts) to do most of the heavy lifting.

  1. Install MacPorts

    MacPorts is an open-source utility that simplifies the installation of other open-source software, including ImageMagick and the various code libraries that it requires to get going.

    The MacPorts site has complete installation instructions.

  2. Install ImageMagick

    After your installation of MacPorts is complete, open the Terminal application, and enter this command on the command line:

    sudo port install ImageMagick
    

    This step can take quite a while to run, over an hour, and at times it may not look like it's doing anything at all. Grab a cup of coffee, and come back when it's done.

  3. Download the matching ImageMagick package

    ImageMagick is now installed, but we still have to install its Perl plugin ("PerlMagick") to let it work with Big Medium and other Perl apps. To get started, go to the ImageMagick site and download the ImageMagick package for the version you just installed. To find out the version number, type this command on the command line:

    port info ImageMagick
    

    When you have the version number in hand, go to the ImageMagick download page and download the ImageMagick package of the same name. I installed version 6.3.0-7, for example, so the package to grab was ImageMagick-6.3.0-7.tar.bz2.

  4. Unzip the ImageMagick package

    If you're unzipping the file from the command line, use these commands (changing the name of the file as necessary to match your version number):

    bzip2 -d ImageMagick-6.3.0-7.tar.bz2
    tar -xvf ImageMagick-6.3.0-7.tar
    
  5. Update PerlMagick's Makefile.PL

    Inside the unzipped Image directory is a directory named PerlMagick:

    cd ImageMagick-6.3.0-7/PerlMagick
    

    Inside that directory is a file named Makefile.PL. You need to make two changes to that file to point to the location where MacPorts installed ImageMagick.

    Find these lines:

    # Header search specfication (sic) and preprocessor flags
    'INC'   => '-I../ -I.. -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/X11R6/include/X11 -I/usr/include/libxml2',
    

    ...and change the second line like so, adding "-I/opt/local/include":

    # Header search specfication (sic) and preprocessor flags
    'INC'   => '-I/opt/local/include -I../ -I.. -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/X11R6/include/X11 -I/usr/include/libxml2',
    

    Then find these lines:

    # Library specification
    'LIBS'  => ['-L/usr/lib -lMagick -L/usr/X11R6/lib64 -L/usr/lib -ltiff -ljpeg -lpng -ldpstk -ldps -lXext -lXt -lSM -lICE -lX11 -lbz2 -lxml2 -lpthread -lm -lpthread'],
    

    ...and change the second line to add "-L/opt/local/lib":

    # Library specification
    'LIBS'  => ['-L/opt/local/lib -L/usr/lib -lMagick -L/usr/X11R6/lib64 -L/usr/lib -ltiff -ljpeg -lpng -ldpstk -ldps -lXext -lXt -lSM -lICE -lX11 -lbz2 -lxml2 -lpthread -lm -lpthread'],
    
  6. Install PerlMagick

    Run the PerlMagick installer by running these commands from the command line:

    perl Makefile.PL
    make
    sudo make install
    

And that's it, you're done. Happy magicking.

Tags: , ,

Want more? Recent blog entries...

Comments

9 comment(s) on this page (times are local Paris time). Add your own comment below.

May 15, 2007 11:34pm [ 1 ]

I tried this and got errors on make test, but so far it seems to have installed OK:

/bin/sh ../magick.sh PERLDLNONLAZY=1 /opt/blocperl/bin/perl "-MExtUtils::Command::MM" "-e" "testharness(0, 'blib/lib', 'blib/arch')" t/*.t t/bzlib/*.t t/jpeg/*.t t/png/*.t t/ps/*.t t/tiff/*.t t/x/*.t t/zlib/*.t ../magick.sh: ../magick.sh: No such file or directory make: *** [testdynamic] Error 127

FWIW my macports version of ImageMagick is 6.3.3-7, which was not in the usual archives online. I finally found it here:

http://image_magick.veidrodis.com/image_magick/

I ended up at your page because (of course) the macports version of perlmagick wouldn't install -- so thanks, you saved me at least half an hour of digging through configs!

SomeGuy
Jul 20, 2007 11:50am [ 2 ]

I also had problems installing the p5-perlmagick port from MacPorts... I think it doesn't match the version of ImageMagick available. The CPAN perlmagick had the same problem.

Anyways reading this blog and following the port info step tipped me off to the fact the the ImageMagick port has a perl variant... so the following line does more or less the same thing, but with less interaction:

port install ImageMagick +perl
erin
Jul 25, 2007 11:21pm [ 3 ]

Hi I was reading your instructions, and if you install ImageMagick using the +no_x11 option it's much quicker:

port install ImageMagick +no_x11

The reason for this is that by default ImageMagick installs X11 which takes ages and you probably don't need it.

Sereg
Aug 16, 2007 10:54pm [ 4 ]

Would you care to elaborate as to how one would actually install Image Magick on a remote server? Anyone?

Thanks.

charles
Sep 19, 2007 7:26pm [ 5 ]

How remote is your server? If your server is anywhere on the network, then you can use ssh to connect to the server. ssh will give you the ability to make all the terminal commands, just as if you are sitting at the server. Naturally, you need to enable ssh on the server. Then, from terminal on your own mac, just type
ssh username@yourservername.something and login to your server

Adam
Oct 25, 2007 11:37pm [ 6 ]

@erin I wish I'd read this prior to starting my install, it's insisting on x11 now! Useful tip I just needed it earlier :)

Hope the author adds it to the main content

Henry
Nov 21, 2007 4:47pm [ 7 ]

Hello, I am trying to install imagemagick and thus far have found no success, I recieve two errors in attempting to install. I am not much of a terminal user, so all my guidence is coming from existing online help.

If I install via: sudo port install ImageMagick

I get the error: invalid command name "destroot.violate_mtree"

If I install via the suggested: port install ImageMagick +no_x11

I get: Error: Unable to execute port: /opt/local/var/macports/build/optlocalvarmacportssourcesrsync.macports.orgreleaseportsgraphicsImageMagick/work/.macports.ImageMagick.state is not writable - check permission on port directory

All help greatly appreciated.

Henry

Josh
Nov 21, 2007 5:16pm [ 8 ]

Thanks to all for the comments and improvements on my original steps. It's on my to-do list to get around to cleaning up the main text above and/or posting another blog entry with the streamlined steps.

Henry, sorry to hear that you're having trouble. This post is just a "here's how I did it" message, and I'm afraid that I'm not able to offer support or troubleshooting. You might check in with the MacPorts mailing list for help. From the sound of it, though, you might have an out-of-date installation of macports. Give this a go:

sudo port selfupdate
sudo port install ImageMagick +no_x11 +perl
pr10n
Dec 22, 2007 5:38pm [ 9 ]

In response to Henry

you need to throw a sudo into the statement

sudo port install ImageMagick +no_x11

Add a Comment

Don't be shy.

( Use Markdown for formatting.)

( )

Download Big Medium
Try it free for 30 days, or buy to unlock.

State of Josh's Brain