views:

58

answers:

2

I'm on OSX Snow Leopard though I think this may not be a platform-specific issue. The problem is I've wasted hours of my life trying to get gem install rmagick to work and I'm hoping to save the next person that grief. I believe the core problem is summed up in the title.

Questions:

  1. Can anyone confirm that Rmagick 2.13.1 doesn't work with ImageMagick 6.6.4?
  2. What's the best solution to getting Rmagick installed on Snow Leopard?
  3. Should MacPorts be used to install ImageMagick? (I couldn't figure out how to tell macports to use an old version of ImageMagick.)

And finally:

Getting ImageMagick to work at all now is giving me fits because I've tried installing various versions in various ways and they're interfering with each other. Below are instructions for purging and reinstalling macports (is that necessary?) but I'm not sure how to clean up other libraries for doing a fresh ImageMagick install. For example, I currently get the following error trying to run ImageMagick

dyld: Library not loaded: /usr/local/lib/libfreetype.6.dylib
  Referenced from: /usr/local/bin/convert
  Reason: Incompatible library version: convert requires version 11.0.0 or later,
          but libfreetype.6.dylib provides version 10.0.0

Perhaps just getting rid of /usr/local/lib/libfreetype* before reinstalling suffices (I'll confirm here when I get ImageMagick working) but is there a more complete/definitive way to do a fresh install of a specific version of ImageMagick?

Appendix: Purging and reinstalling MacPorts

+1  A: 

RMagick is an... interesting library. If at all possible, avoid it's usage. If you're just resizing images and other basic things, look at minimagick. The main issue with RMagick stems from memory usage and leaks - not usually apparent in development, but in production they get ugly fast.

My advice would be to look at alternatives if at all possible - if you have to do more complex work, it might actually be preferable to use Python/PIL for that instead (wrapped with Ruby - I use this to get at OpenCV, for example). Depends on your use case.

If you really need RMagick, then Homebrew might work better than ports. I'm a Linux guy where this stuff tends to Just Work, and over there the definitive way to get things like ImageMagick set up properly outside of package managers is to build it from source. Not sure how practical that is on OSX, but it might be worth a shot if all else fails.

JamesHarrison
This is a great answer. It may make sense for me to switch to minimagick; I had not considered that. I had gotten the impression that Rmagick was the industry-standard thing to use. Apparently not so when performance matters. Thanks again for the help and advice. I'm still hopeful we can get a definitive answer to this for mac users who do need Rmagick though.
dreeves
A: 

Fundamentally, the answer indeed seems to be that you need an older version of ImageMagick for Rmagick to work (at least under Snow Leopard).

I've confirmed that ImageMagick 6.5.6-10 works with Rmagick 2.13.1. (Rmagick homepage says it's been tested up through ImageMagick 6.6.1-0. Version 6.6.1-0 doesn't seem to be available but probably 6.6.1-10, which is available, is fine too.)

All the troubles with MacPorts were probably mostly red herrings. Still, MacPorts does not seem to have a way to install a previous version of ImageMagick so I installed it from source. HomeBrew might be a better option.

The errors I was getting with ImageMagick were solved for me by removing /usr/local/lib/libfreetype* and reinstalling ImageMagick. I also purged and reinstalled MacPorts but I don't know that that was necessary.

Here are the exact steps I took to get this working, as best as I can reconstruct them.

  1. Purge and reinstall MacPorts (see appendix of the question above).
  2. Remove /usr/local/lib/libfreetype*
  3. sudo port -v install freetype +bytecode
  4. sudo port -v install librsvg
  5. I didn't do this but some people might want: sudo port -v install graphviz +gs +wmf +jbig +jpeg2 +lcms
  6. cd /usr/local/src
  7. curl 'ftp://ftp.imagemagick.org/pub/ImageMagick/legacy/ImageMagick-6.5.6-10.tar.gz' > ImageMagick-6.5.6-10.tar.gz (This will probably work too: ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.6.1-10.tar.gz)
  8. tar xzvf ImageMagick-6.5.6-10.tar.gz
  9. cd into there but don't follow the instructions in Install-whatever.txt because they're all fucked up.
  10. export CPPFLAGS=-I/usr/local/include
  11. export LDFLAGS=-L/usr/local/lib
  12. ./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp --with-gs-font-dir=/usr/local/share/ghostscript/fonts
  13. make
  14. sudo make install
  15. gem install rmagick

Phew! Note that steps 3-14 could probably be replaced with this: http://github.com/masterkain/ImageMagick-sl

dreeves