Global Moxie

http://globalmoxie.com/blog/imagemagick-install-osx.shtml

Installing ImageMagick on OSX

I installed ImageMagick on a Mac OSX server this week and figured I'd share the necessary steps and details.

By

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: , ,