thoughts from left field
Wednesday, March 22, 2006
  Mac OS X & Rails & ImageMagick without the kruft
Recently I got one of the new Intel iMacs, and I wanted to move all my Rails development over to it. Most things went very easily, however ImageMagick doesn't seem to have a binary for Intel Macs just yet. I decided to try and install it from source. It was actually very easy to do. So if you don't feel like installing Darwin Ports/Fink just to get ImageMagick read on.

If you're not comfortable dealing with the Terminal/shell access then you may want to wait for the binary release, or go the Darwin Ports/Fink route.

Ideally you should have followed the Rails installation tutorial at Hivelogic.

Basically you need to have your path setup to look in /usr/local/bin for binaries. If you need help doing that, have a look at the aforementioned article.

Start up Terminal(usually located in the /Applications folder).

At the prompt enter:

mkdir src
cd src


Now we're ready to get and install the required software.

Note: the order here is important.

PNG


This supports PNG files. If you don't need support you can safely skip it.

curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.8-config.tar.gz
tar zxvf libpng-1.2.8-config.tar.gz
cd libpng-1.2.8-config
./configure --prefix=/usr/local
make
sudo make install

Notes:

JPEG


Pretty much everyone needs this. Unfortunately it's the most troublesome to compile and
install correctly. Follow the directions carefully. Note: The single quotes in the fourth line
are backquotes, not regular quotes. (see the tilda key)

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

TIFF


Everyone needs this as well.

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

ImageMagick


The big tamale! The [VERSION] tag below denotes the version of ImageMagick you actually got. ImageMagick.tar.gz is a link to the latest version of ImageMagick, so the version will change as they do new releases.

curl -O ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar zxvf ImageMagick.tar.gz
cd ImageMagick-[VERSION]
./configure --without-perl
make
sudo make install

Updated to use the latest version via the linked file.

RMagick


One more step, add the ruby bindings to ImageMagick. You may get some errors during the Rdoc
install phase, you can safely ignore them.

sudo gem install rmagick


Woot! You're done. Have a beverage, and get down to work.
 
Comments:
This works great! Thank you.
 
Many thanks for such a great tutorial. I've followed it successfully several times. Now, where did I leave my beverage...
 
Just some notes:

In the steps for JPEG there's a period missing, it should be:

./configure --enable-shared --prefix=/usr/local

and when I did this the version of tiff was up to 3.8.2. Replace all of the 3.8.1 in the tiff instructions with 3.8.2 you should be golden.

Finally, libpng wasn't available from simplesystems the day I did it. I picked up the latest from

http://www.libpng.org/pub/png/libpng.html
 
Thanks Dave, I've updated the post to correct the missing period, and changed tiff to 3.8.2.
 
libpng is no longer available on the link posted. Get it from one of the sourceforge downloads linked from the official home page http://www.libpng.org/pub/png/libpng.html
 
Don't get me wrong, I love the tutorials, and I am glad this is all being well documented. But between Rails and ImageMagick, DarwinPorts is the way to go. I have installed everything through it, and it is just works so well.
 
ImageMagick is up to 6.4.7-0. Trying the install now, hopefully all will be ok
 
Your curl statement for ImageMagick does not work they are on 6.2.7-0. Other than that great tutorial. It seems all the libraries are being updated right after you change their listings. :)
 
Hey Adam,

I totally agree that Darwin Ports and Fink are excellent ways to get all this running. For many people that is a much better route to take.

I however like just having the software I need without adding an entirely new management framework and a boat load of other bloat. The ImageMagick that comes with Darwin Ports/Fink is compiled with pretty much every option turned on. I don't really need 80% of the features that IM offers, so it just seemed easier to roll my own.
 
I got some issue with imagemagick and libpng 1.2.10, back to 1.2.8 everything was fine...
thanks!
 
THANK YOU good man!

I jumped onto the intel bandwagon without really thinking it over (the filthy alure of PC game whores). And then: Wheres imagemagick for intel macs???!? Since I am not into the "sudo" midst of things, I was done for.

Thanks!!!!
 
the current version of libpng is 2.1.10. it no longer ships with the configure option. and didn't see a valid makefile in the script dir which worked with osx intel. got the 2.1.8 from sourceforge
 
Thanks a ton. This worked great on the intel mac. I had no problems with the libpng-1.2.10. I have XCode 2.3 that just shipped - maybe that fixes the problem some have reported.
 
Something's still missing. I tried going through this (in the console):

http://rmagick.rubyforge.org/web2/web2.html

and when I got to this statement:

gc.annotate(background, 0, 0, 70, HEIGHT, "RMAGICK")

I get errors:

sh: line 1: gs: command not found
sh: line 1: gs: command not found
RMagick: no decode delegate for this image format `/var/tmp/magick-Cg1JykLQ'.
RMagick: Postscript delegate failed `/var/tmp/magick-Cg1JykLQ'.
sh: line 1: gs: command not found
sh: line 1: gs: command not found
RMagick: no decode delegate for this image format `/var/tmp/magick-zCiPCyGp'.
RMagick: Postscript delegate failed `/var/tmp/magick-zCiPCyGp'.
=> (no primitives defined)


Huh?!?

I also get errors when trying to do a gem update.

Anyone?
 
This is a great tutorial ... saved me a lot of hassle and worked like a treat!

The only teeny weeny suggestion I'd make is adding in the command cd .. at the end of each bit you install because if you follow your instructions literally you get end up with a 'unique' directory structure!
 
Unfortunately

http://www.ijg.org

doesn't seem to exist now
 
great it works perfect
system here is G4 Double proc 2x1.4 GHz with 1GB RAM, OS 10.4.8

regards Frank
 
Anonymous, if you get this error,
"sh: line 1: gs: command not found" it simply means that you do not have ghostscript installed on your machine or the executable location is not in your path. A simple way to get gs is by installing fink and installing the gs package.
 
As others have said... great tutorial.

My addition:

When running the jpeg configure script I got an error:
ltconfig: cannot guess host type; you must specify one

I was running this on an intel Mac mini by the way. The command 'uname -m' shows what you are looking for... in my case 'i386' is the host type.

I opened up the 'configure' script, and found the line where it runs ltconfig and added 'i386' to the end of the line (no quotes of course).

Thanks again,
Malcolm
 
Hello,

Great tutorial. I've used it in the past without problems. But I'm getting some problems now on a fresh machine...

This is from the gem install step:
RMagick: FreeTypeLibraryIsNotAvailable `(null)'.
RMagick: no decode delegate for this image format `/var/tmp/magick-ea4gs8oj'.
RMagick: Postscript delegate failed `/var/tmp/magick-ea4gs8oj'.

And later on, I see that an error that not enough tests passed.

Any thoughts?

Thanks,

Matt
 
This post has been removed by the author.
 
Thank you for this clean step by step installation guide.

I am on an Intel Mac OS X 10.4. All the steps went well so far. I am psyched to try it.

[me@my-machine] irb
>> require 'rmagick'
=> true

GREAT!
 
For the record, this works on Leopard.
 
Let me add my thank you to the rest. It worked perfectly. Also, thanks to Malcolm for his comment on solving the issue with the jpeg configure script.
 
For those with problems like gs not found,
change the pathes in
/usr/local/lib/ImageMagick-*/config/delegates.xml
for the gs delegate entries.
Take care gs will (if installed) most likely be in /usr/local/bin and that path might or might not be in your path hence the trouble.
You can also configure ImageMagick with --frozen-pathes then paths for found delegates will be absolute...


take care
paradoxix
 
Post a Comment



<< Home

Name: Will Groppe
ARCHIVES
March 2006 /


Powered by Blogger