Skip to content

Installing ImageMagick/RMagick on Leopard

I’ve heard many horror stories of developers trying to install ImageMagick/RMagick to manipulate images. Fortunately, when I needed to install RMagick to use with the attachment_fu plugin, I ran across a fantastic script at OnRails.org by Solomon White (many thanks). It gave the steps to install RMagick from source without MacPorts or Fink.

I made the following minor changes to get it working for me and posted the script below.

  • Changed ‘wget’ to ‘curl -O’
  • Updated a couple of links that weren’t working for me
  • Updated sourceforge links to the east coast
  • Updated links to latest version of source code (as of today)
#!/bin/sh
curl -O http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz
tar xzvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local
make
sudo make install
cd ..

curl -O http://superb-east.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.23.tar.bz2
tar jxvf libpng-1.2.23.tar.bz2
cd libpng-1.2.23
./configure --prefix=/usr/local
make
sudo make install
cd ..

curl -O http://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar xzvf jpegsrc.v6b.tar.gz
cd jpeg-6b
ln -s `which glibtool` ./libtool
export MACOSX_DEPLOYMENT_TARGET=10.5
./configure --enable-shared --prefix=/usr/local
make
sudo make install
cd ..

curl -O ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz
tar xzvf tiff-3.8.2.tar.gz
cd tiff-3.8.2
./configure --prefix=/usr/local
make
sudo make install
cd ..

curl -O http://superb-east.dl.sourceforge.net/sourceforge/wvware/libwmf-0.2.8.4.tar.gz
tar xzvf libwmf-0.2.8.4.tar.gz
cd libwmf-0.2.8.4
make clean
./configure
make
sudo make install
cd ..

curl -O http://www.littlecms.com/lcms-1.17.tar.gz
tar xzvf lcms-1.17.tar.gz
cd lcms-1.17
make clean
./configure
make
sudo make install
cd ..

curl -O http://superb-east.dl.sourceforge.net/sourceforge/ghostscript/ghostscript-8.61.tar.gz
tar zxvf ghostscript-8.61.tar.gz
cd ghostscript-8.61/
./configure  --prefix=/usr/local
make
sudo make install
cd ..

curl -O http://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/current/ghostscript-fonts-std-8.11.tar.gz
tar zxvf ghostscript-fonts-std-8.11.tar.gz
sudo mv fonts /usr/local/share/ghostscript

curl -O ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.3.7-1.tar.gz
tar xzvf ImageMagick-6.3.7-1.tar.gz
cd ImageMagick-6.3.7
export CPPFLAGS=-I/usr/local/include
export LDFLAGS=-L/usr/local/lib
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts
make
sudo make install
cd ..

To test that ImageMagick was installed properly you can check the version number.

convert -version

[you should see something like this]
Version: ImageMagick 6.3.7 11/26/07 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC

To test that ImageMagick is working properly you can run the following test. It will create a copy of the ImageMagick logo.

convert logo: logo.gif

Comments

  1. James December 21st, 2007 | 5:29 am

    Many thanks for this, it really helped.

  2. Sman January 4th, 2008 | 5:10 pm

    I am curious about something and have been unsuccessful in resolving it. I can easily install ImageMagick on Leopard. What I am having a hard time with is getting the correct gem for 6.3.7. The RMagick gem I keep getting is built for a different version of ImageMagick making it impossible to get this thing working. I am kinda new at the rails environment, so I could be just doing something wrong. Do you have the correct gem and can verify it works in the rails framework. Just an FYI, convert -version works fine with my ImagicMagick install. Its the in rails app usage that fails. Thanks in advance.

  3. John Ford January 7th, 2008 | 1:50 pm

    Hi Sman, I’m running ImageMagick 6.3.7 and the gem rmagick 2.0.0 on my local machine. I’m using attachment_fu in one of my projects and images are being resized properly. I just now tested again to make sure.

  4. Craig February 29th, 2008 | 1:18 am

    Has anyone ran into the problem of the littlecms website being down and therefor unable to download the source? If so, does anyone know of any mirrors to download it from. I have been googling for the last little while and have not been able to find anything.

  5. John Ford February 29th, 2008 | 7:15 am

    Hi Craig, the littlecms site seems to be coming up okay now.

  6. CodeOfficer March 3rd, 2008 | 4:25 am

    I’ve run into a snag with the script over at OnRails … i *thought* everything was working fine for a week or two … my rails project using attachment fu let me upload images, and would create the thumbnails sizes I asked for … BUT … it would nto do so if the original image was a jpg.

    I’m going to try this more recent version of the script and hope for the best :)

    Any thoughts on why jpgs would be an issue? anyone else had that problem with leopard?

  7. Guillermo Rauch March 16th, 2008 | 6:34 pm

    Nice work! Did the job perfectly.

  8. Tim Peat March 17th, 2008 | 8:10 pm

    Many thanks to you and Solomom for sharing this.

  9. Josh May 2nd, 2008 | 7:07 am

    Thanks for sharing this… had to change some URLs and stuff to get it work, but it helped a lot!

  10. Brian Fury May 15th, 2008 | 8:31 pm

    For people like me who do not have X11 installed on their Leopard machine, this may help:

    I needed to add a
    with-x=no
    to the end of the
    ./configure [...]
    line, four lines up from the end of the script, in order for ImageMagick to install.

    Thanks for the script though!

  11. John WUlff June 25th, 2008 | 1:54 pm

    Thanks!

  12. Tom June 27th, 2008 | 11:00 am

    I had some problems with the last couple groups of commands. I don’t know if ImageMagick 6.3.7-1 is still available on their ftp?

  13. Jamie June 27th, 2008 | 6:15 pm

    Hey John, thanks a lot to you and Solomon for blogging this!

    Tom: I modified John’s script slightly to use the latest versions from mirrors near me (UK). ImageMagick is currently at 6.4.2-0, so try:

    curl -O ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.4.2-0.tar.gz

    Hope this helps!

  14. Don French September 3rd, 2008 | 4:55 am

    I get the following error when trying to run his script:
    Undefined symbols:
    “_iconv_close”, referenced from:
    _opvp_to_utf8 in gdevopvp.o
    “_iconv”, referenced from:
    _opvp_to_utf8 in gdevopvp.o
    “_iconv_open”, referenced from:
    _opvp_to_utf8 in gdevopvp.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [bin/gs] Error 1

    Any ideas what is missing?

  15. Darren October 15th, 2008 | 7:12 pm

    ImageMagick-6.4.4 release doesn’t have the configure so you just unpack and configure your environment paths correctly and your good to go. I posted about it on my site. ;) Hope that helps someone out cause it frustrated the hell out of me.

  16. arctan December 8th, 2008 | 10:39 pm

    @Don French

    i had the same problem on 10.5 while compiling ghostscript. my fix involved downloading libiconv and compiling that. then make clean on ghostscript (imagemagick in your case) and then make -j1

  17. Pat February 6th, 2009 | 3:33 pm

    Thank you!! Fantastic help.

    I was just trying to run the unit tests for Paperclip on my Mac and realized they relied on ImageMagick… this script saved me!

  18. Benny August 2nd, 2009 | 10:07 am

    I have tried to install ImageMagick for 2 weeks on Mac OS Leopard without success. Everybody talked about usr/local/bin and I was not able to install it in that directory. Thanks to this script I could. I only used the last 9 lines of the script that installs ImageMagick, is that wrong? I still have a problem. I can use ImageMagick from the terminal and it works perfect. But why can’t I use it from PHP code with the exec command?

  19. John Ford August 3rd, 2009 | 12:20 pm

    @Benny, you may have to recompile PHP with the GD flag to enable it. When I compile PHP on my system it looks something like this:

    ./configure \
    --prefix=/usr \
    --with-apxs2 \
    --with-curl \
    --enable-fastcgi \
    --enable-zip \
    --with-zlib=/usr \
    --enable-ftp \
    --enable-sockets \
    --with-openssl \
    --with-ldap=/usr \
    --with-kerberos=/usr \
    --enable-cli \
    --with-xmlrpc \
    --with-xsl=/usr \
    --with-mysql=/usr/local/mysql \
    --with-mysql-sock=/tmp/mysql.sock \
    --with-mysqli=/usr/local/mysql/bin/mysql_config \
    --with-gd \
    --with-jpeg-dir=/usr/local/lib \
    --with-png-dir=/usr/X11R6 \
    --with-freetype-dir=/usr/X11R6 \
    --with-xpm-dir=/usr/X11R6 \
    --enable-exif \
    --with-mcrypt \
    --with-pdo-mysql=/usr/local/mysql/bin/mysql_config
    

Leave a reply