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.
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.
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.
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.
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
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'],
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:
imagemagick,
osx,
software
Want more?
Recent blog entries...
More from this section
The Future in Your Pocket, and Why I'm Writing Another BookMy new book,
Best iPhone Apps, comes straight out of my childhood yearning for this very device.
iWork ’09 Tips, Interviews, and Book ReviewsI hit the bricks this month to spread the word about my book,
iWork ‘09: The Missing Manual.
Marathons, Makers, and Surviving the Dark MiddleIn the dark middle of the race, runners need encouragement, reminders that they're strong, that the finish is ahead: plausible, real, within reach.
Message from BeyondA missive from quite another big medium arrives in my mailbox.
David Byrne Never Stops Making SenseDavid Byrne's concert in Paris was an inspiring reminder of the simple pleasure of sharing the amazing stuff you make.
My Latest Project: A BookI signed a contract last month with O’Reilly to write a book about Apple’s iWork software, and I couldn’t be more tickled.
Dot Your I’sA clever logo solution smuggles in the required legalese without cluttering the design.
Jacques Villeglé: The Original MashupAn exhibition of torn poster art asks fascinatingly relevant questions in an era of online mashups and user-generated content.
Winning the Uphill BattleParis solves a problem with its bike-sharing program by turning hill-climbing into a game.
Comments
14 comment(s) on this page. Add your own comment below.
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!
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 infostep 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:Hi I was reading your instructions, and if you install ImageMagick using the +no_x11 option it's much quicker:
port install ImageMagick +no_x11The reason for this is that by default ImageMagick installs X11 which takes ages and you probably don't need it.
Would you care to elaborate as to how one would actually install Image Magick on a remote server? Anyone?
Thanks.
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
@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
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
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:
In response to Henry
you need to throw a sudo into the statement
sudo port install ImageMagick +no_x11
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!
@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.
Remove all versions of imagemagick currently installed. (Hopefully there's only one. If not, follow the version prompts exactly.)
% sudo port uninstall Imagemagick
Upgrade your Mac's xcode tools to 3.1.2 (found on apple's website. Signin with free developer account needed)
Reboot
Update your MacPorts libraries
% sudo port selfupdate
Install ImageMagick using MacPorts
% sudo port install ImageMagick +perl
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.
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
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:
Followed by this error when running sudo make:
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
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!
Add a Comment
Don't be shy.