Blog

Or search support forum

What's Global Moxie?

Global Moxie specializes in mobile design strategy and user experience for a multiscreen world. We offer consulting services, training, and product-invention workshops to help creative organizations build tapworthy mobile apps and effective websites. We're based in Brooklyn, NY. Learn more.

On Shelves

Books by Josh Clark

Tapworthy: Designing Great iPhone Apps

Best iPhone Apps: The Guide for Discriminating Downloaders

iWork ’09: The Mising Manual

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

21 comment(s) on this page. Add your own comment below.

May 15, 2007 5: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 5: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 5: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 4: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 1: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 5: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 10:47am [ 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 11:16am [ 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 11:38am [ 9 ]

In response to Henry

you need to throw a sudo into the statement

sudo port install ImageMagick +no_x11

Stephen
Jan 6, 2009 3:40pm [ 10 ]

Hi, any help would be much appreciated. I know nothing about unix and servers, but have been working with drupal and decided to install one of the image upload and manipulation modules with need this app.

I'm getting errors??? I have a macbook pro with version 10.5.6 for OS.

I installed x11 and haven't had too many problems with this tutorial until I get to step six. The terminal gives me these errors:

Note (probably harmless): No library found for -lMagick Note (probably harmless): No library found for -ldpstk Note (probably harmless): No library found for -ldps Note (probably harmless): No library found for -lXext Note (probably harmless): No library found for -lXt Note (probably harmless): No library found for -lSM Note (probably harmless): No library found for -lICE Note (probably harmless): No library found for -lX11

Then: cc1: error: unrecognized command line option "-fopenmp" lipo: can't open input file: /var/folders/Uo/UoJVZyo3G30wEHYjNF-mFk+++TI/-Tmp-//ccxwRln5.out (No such file or directory) make: * [Magick.o] Error 1

I still tried the command sudo make which gave me an error as well. cc1: error: unrecognized command line option "-fopenmp" lipo: can't open input file: /var/tmp//ccOQUX8L.out (No such file or directory) make: * [Magick.o] Error 1

Thanks!

Jan 9, 2009 8:54pm [ 11 ]

@Stephen:

You have the exact same problem I just experienced, and fixed. I was running Drupal 6 on a localhost server and trying to get Imagecache + imageAPI modules working with Imagemagick via MacPorts. The steps to get yourself back in the game are as follows.

  1. Remove all versions of imagemagick currently installed. (Hopefully there's only one. If not, follow the version prompts exactly.)
    % sudo port uninstall Imagemagick

  2. Upgrade your Mac's xcode tools to 3.1.2 (found on apple's website. Signin with free developer account needed)

  3. Reboot

  4. Update your MacPorts libraries
    % sudo port selfupdate

  5. Install ImageMagick using MacPorts
    % sudo port install ImageMagick +perl

  6. Verify that your installation worked
    % convert -v

You should see output that looks like this:
Version: ImageMagick 6.4.8 2009-01-09 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

Usage: convert [options ...] file [ [options ...] file ...] [options ...] file

...

If you see that, you're golden! Good luck.

Jan 9, 2009 8:57pm [ 12 ]

Followup comment to myself. Drupal's imageAPI module needs to know the path of /opt/local/bin/convert in order to enable the ImageMagick settings at admin/settings/imageapi/config/imageapi_imagemagick

Mar 2, 2009 2:07pm [ 13 ]

I'm in the same boat as Stephen, except that I'm running 10.4.11 on a GigE dual 450. I followed Senpai's directions (I was only able to upgrade to XCode Tools 2.5) and still get the errors when trying to compile PerlMagick:

Note (probably harmless): No library found for -lMagick
Note (probably harmless): No library found for -ldpstk
Note (probably harmless): No library found for -ldps
Note (probably harmless): No library found for -lXext
Note (probably harmless): No library found for -lXt
Note (probably harmless): No library found for -lSM
Note (probably harmless): No library found for -lICE
Note (probably harmless): No library found for -lX11

Followed by this error when running sudo make:

cc1: error: unrecognized command line option "-fopenmp"
make: *** [Magick.o] Error 1

Clearly, ImageMagick is on the hard drive; clearly I've changed the Makefile.PL to point to the new places; I'm stumped.

I'd appreciate any thoughts or insights anyone might have.

Thanks.

\dmc

khabela
May 24, 2009 9:19am [ 14 ]

I know you do not offer support for this, but maybe someone else who reads this can help out???

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/optlocalvarmacportssourcesrsync.macports.orgreleaseportsarchiversbzip2/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!

Paul Backhurst
Jul 28, 2009 2:35am [ 15 ]

khabela,

You need to install gcc (a c-compiler). You can get this by visiting http://developer.apple.com/mac/ and creating a free ADC Online Membership. Then, you need to download the newest version of Xcode 3. Double click on XcodeTools.mpkg once the .dmg has been mounted. The install lasts a while (40 mins?) if there are no Xcode tools on your system, otherwise it can install very quickly by just installing what your missing.

Regards,

Paul

Paul Chernoch
Aug 8, 2009 8:55pm [ 16 ]

Thank you for the discussion and various solutions. senpai's six-part answer (using "sudo port install ImageMagick +perl") worked for me like a charm. (I skipped the xcode upgrade and reboot as I already have a current version.)

  • Paul
mini
Mar 4, 2010 5:19am [ 17 ]

Iam windows user migrating to mac..having tough time to install imagemagicks .. Iam not able to use fonts.. this is the test command iam trying to run..and it says font not found..please help

convert bg.jpg -font times-roman -pointsize 22 -annotate 0 'mini' final.jpg though there are many fonts imagemagicks is not recognising any of them. error message is this : convert: unable to read font `/usr/local/lib/ImageMagick-6.5.8/config//usr/local/share/ghostscript/n021003l.pfb' @ annotate.c/RenderFreetype/1043.

Forrest
Apr 23, 2010 5:39am [ 18 ]

I hope to know more friends who are interested about imagemagick here. I have several years experience for opencv , and hope to communicate with friends about tech. SKYPE me with forrest.shi thanks

Oct 26, 2010 8:16pm [ 19 ]

I used the originally posted method to (re)install ImageMagick with Perl (PerlMagick) support on a OS X 10.5.8 Leopard (PPC) workstation, which I use as a mail/web server.

The gotcha I've been suffering is that the PerlMagick build instructions seem to have slipped in OpenMP (parallel processing) support since I first installed it three years back. For anyone using the stock gcc 4.0.1 or earlier compiler, this results in the error David noted:

cc1: error: unrecognized command line option "-fopenmp"

One could upgrade to Snow Leopard and Xcode 3.2, or using Macports to install gcc 4.5.2. The easier method is to remove "-fopenmp" where it appears in ImageMagick[version]/PerlMagick/Makefile.PL, before running any of the make process.

mbek
Jan 6, 2011 12:16am [ 20 ]

thanxs dude..

your solution help me a lot...

thanxs again

Mart
Feb 28, 2011 8:29am [ 21 ]

After installing imagemagick via macport and magickperl as showed, imagemagick works great, but not magickperl. The reason is that macport installs a new version of perl on Mac os X 10.6.6 under /opt/local/bin/perl (Version 5.12.3). Calling a perlscript via automator i get an error: Can not find Magick.pm under @INC!! - because INC is set from the preinstalled perl-version on my imac under /usr/bin/perl (Version 5.10.0)! So, I took a backup of /usr/bin/perl (sudo cp /usr/bin/perl /usr/bin/perl-backup) and replaced with a symlink to the macports install of perl sudo ln -s /opt/local/bin/perl perl Now its using the newer version of Perl installed via Macports, which seems to find Image::Magick just fine now, so everything works on that front.

Add a Comment

Don't be shy.

(Use Markdown for formatting.)

This question helps prevent spam:

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

Listen Up

“I listen to what Josh Clark has to say.”
—Matt Legend Gemmell, developer, Instinctive Code

“Tapworthy is a great iPhone development book.”
—Joe Hewitt, creator of the Facebook iPhone app

“I snagged a copy of Josh Clark’s Tapworthy. Mmmm... that’s good interface.
—Boon Sheridan