Really Truly Getting ImageMagick & RMagick Working on OSX from Source without Using MacPorts(DarwinPorts) or Fink

Posted by labrat

6/22/2007 Please check out an updated version here: http://pastie.caboo.se/72596

The impatient can simply grab the shell script and run with it.

It was basically an issue of configuring the right load paths for ImageMagick.

My Story (After Wasting So Much Time I Had to Share This)

So here’s the scenario, I come back to an office mac I haven’t touched for months and try to get image manipulation working in my toy rails app. But instead of working, when I go to the image section, the whole thing explodes. All the other parts are working fine. Something, like a dreaded “bus error” or such.

Hmmm… I got all this working on a clunky iBook so it must be easy. Or so I thought…

After stumbling about on the net and ruining a perfectly working configuration of ImageMagick on my iBook (that takes forever to compile this stuff) as well, I finally got the whole thing working (on my intel mac at least).

Turns out I needed to properly configure the load paths for ImageMagick and set them straight in my .bash_profile.

To save you the trouble, I’ve prepared a shell script that you can run by downloading it somewhere and simply typing:

    sudo sh rmagick_imagemagick_redo_osx.sh

Please review the shell script thoroughly. Running it as sudo will save you from typing the password at regular intervals for the “make install” step but it also means you’re handing over your computer.

I don’t have any destructive actions such as “remove” in the script so at most you’ll get a bunch of unwanted source files in a folder you can delete later (conveniently labeled “delete_this_later”).

Comments

Leave a response

  1. Victor RosilloOctober 12, 2006 @ 08:11 PM
    Thanks a lot !!! Finally it fixed the problem for me too !!!
  2. LabratOctober 13, 2006 @ 09:51 AM
    Thanks for the feedback. I'm happy to know it works for others as well.
  3. Victor RosilloOctober 19, 2006 @ 05:35 AM
    I am running OSX Tiger 10.4.8 The problem; after installing as said with the above shell script and going to irb and doing require 'RMagick' and getting: true ; I thought that everything was ok, by the way under rails script/console now works perfect. But the problem came when doing the "annotation" example here: http://studio.imagemagick.org/RMagick/doc/usage.html I got this error: Magick::ImageMagickError: unable to read font `/usr/local/share/ghostscript/fonts/n019003l.pfb' method annotate in annotate.rb at line 16 at top level in annotate.rb at line 16 So i discovered that I don't have the ghostscript fonts under said dir; and I saw that using your shell script in the installing imagemagick section it has this: ./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 but in the script ghostscript is never installed, so how can those fonts be there?! If I go into iterm and do this: identify -list type i get this: Path: /usr/local/lib/ImageMagick-6.2.9/config/type-ghostscript.xml Name Family Style Stretch Weight -------------------------------------------------------------------------------- AvantGarde-Book AvantGarde Normal Normal 400 . . . and a listing of lots of fonts!!! If I go under irb and do this: require 'RMagick' i get: true then: Magick.fonts i get a list of the fonts that ×Magick knows about So then why I am getting this error? : Magick::ImageMagickError: unable to read font `/usr/local/share/ghostscript/fonts/n019003l.pfb' So I went to see my /usr/local/share dir and certainly there is no ghostscript dir!!! So I fixed it partially but don't have ghostscript installed and i would like to have it installed. How i worked it arround?; I downloaded the fonts file: ghostscript-fonts-std-8.11.tar.gz from here: ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/current/ and then created the ghostscript and fonts dirs using sudo mkdir ghostscript and sudo mkdir fonts and then copied the downloaded fonts into the /usr/local/share/ghostscript/fonts dir But I do not have ghostscript installed , so i would like to have you, PLEASE, include it in the installation of your shell script with the correct parameters. meanwhile I really do not know if i did it correctly to have this workaround, it works but i have not tried other things in RMagick that might depend on having ghostscipt correctly installed and will eventually break!!! LabRatZ, please help!!! and thanks a lot for all your support ;-)
  4. LabratOctober 19, 2006 @ 11:15 AM
    victor, That's true. Sorry for the oversight. I use LateX and the pre-install package put ghostscript in the proper place for me. What you did is not a work around but actually the correct way as you can see from the blog below. I think ImageMagick just needs the gs fonts and not the program itself so you should be safe, but if you want gs as well, the following should set you straight (although you'll simply be redoing the font copying). For GhostScript support check out this post: http://scoops.totallyrule.com/articles/2006/06/20/rmagick-on-osx-revisited That should get you GS support. After you do that type "gs --help" to check where it got installed as well as the version and other stuff. Something like the following(adapted from the blog above): curl http://superb-east.dl.sourceforge.net/sourceforge/ghostscript/ghostscript-8.54-gpl.tar.gz | tar xfz - cd ghostscript-8.54-gpl/ ./configure --prefix=/usr/local make sudo make install cd ~/$dir curl ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/current/ghostscript-fonts-std-8.11.tar.gz | tar xfz - sudo mv fonts /usr/local/share/ghostscript If I see other people needing it, I'll modify the script accordingly but since they are both big libraries, this comment will be all the support I give it. Hope this helps and sorry for the confusion. BTW, the blog uses spam filtering so I have all 7 comments you submitted. ;)
  5. GregJanuary 16, 2007 @ 03:29 PM

    Appears to have worked like a charm! Thanks so much – and thanks for prefixing everything with /usr/local… Cheers!

  6. labrat January 19, 2007 @ 07:22 PM

    DH has been murdering my rails blog. Thanks so much for the comment. I’m glad people found it useful!

  7. elmoJanuary 26, 2007 @ 11:53 AM

    Thank you for this marvelous work! I blew a whole day dealing with this before coming upon your tutorial. Thanks again!

  8. ChrisMarch 21, 2007 @ 08:51 AM

    After writing this post about the pain of installing *Magick, I’d pretty much given up until I found your script. Looks like it might have done it.

    Dude, you are my hero.

  9. Ryan ErwinMay 14, 2007 @ 11:48 PM

    Thank you soooo much! That worked great for me. To get the install to run, I had to do a apt-get remove the imagemagick packages from my fink install.

    $ apt-cache search imagemagick | awk ‘{print $1}’ | xargs sudo apt-get remove

    Then, I kept getting errors about not being able to find a ghostscript font, but linking libwmf to the (non-existant) ghostscript folder fixed that:

    $ sudo ln -s /usr/local/share/libwmf /usr/local/share/ghostscript

    In any case, thanks so much for writing this. It was very helpful and saved me a ton of time. I tried to get ImageMagick up on my MacBook a month or so ago, but didn’t find this at the time and didn’t manage to get it working ;-)

    Thank you for doing the leg work and figuring out the right set of dependancies!!!

    -Ryan Erwin Shanghai, China www.ryanerwin.com

  10. ChrisJune 22, 2007 @ 08:13 AM

    The versions in this script are outdated now and will either not be found or throw compilation errors. To fix that, swap in these versions as of this posting date:

    echo installing imagemagick curl -O ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.3.4-10.tar.gz tar xzvf ImageMagick-6.3.4-10.tar.gz cd ImageMagick-6.3.4 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 ~/$dir

    echo now for rmagick! curl -O http://rubyforge.rubyuser.de/rmagick/RMagick-1.15.7.tar.gz tar xvzf RMagick-1.15.7.tar.gz cd RMagick-1.15.7 make clean ./configure make sudo make install cd ~/$dir

  11. KWDecember 15, 2007 @ 09:26 AM

    Thanks alot.. I just reinstalled Rmagick out of necessity on my ibook.. I wiped my hard drive not too long ago. Last time I did this it tooke me two days to figure out. This time it only took about an hour.. One thing I need to point out is that the link for imagemagick in the shell script is no good.. I updated two links two make it work.. line 73 should read curl -O ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.3.2-9.tar.gz

    and line 84 should be curl -O http://rubyforge.rubyuser.de/rmagick/RMagick-1.15.8.tar.gz

    as of 12/14/2007… I had a problem on my first run because it couldn’t find imagemagick.. So if you have these problems make sure and substitue for current versions of everything that needs to be installed.. Once again, thank you for your work.. I love shell scripts for automation..

Thanks for the comment!