installing ImageScience an art?

ImageScience is a pretty cool gem to use in your Rails application for Thumbnail generation.  It doesn't install correctly out of the box since ImageScience uses an incorrect default path for locating FreeImage. The Makefile shipped with FreeImage also does not build correctly on OpenSolaris.  So here's a way to make sure it works correctly first time if you are on OpenSolaris.

Step1:  Update your Ruby package.  We now package Ruby 1.8.7 p72 with OpenSolaris.  Here is a blog entry I wrote sometime ago on how to upgrade to 1.8.7p72 -> http://blogs.sun.com/prashant/entry/how_does_one_update_ruby

Step2: Ensure that /usr/gnu/bin is prepended to your PATH environment variable. (or, just utter export PATH=/usr/gnu/bin:$PATH in bash).

Step3: Install the requisite OpenSolaris packages.

pfexec pkg install SUNWgmake

pfexec pkg install SUNWgnu-coreutils

The "pfexec" is there to give you enough privileges to install the packages.  If you run as root(which I do - and which is not recommended), then you don't need to use pfexec.

Step4: Build FreeImage. Download it from http://downloads.sourceforge.net/freeimage/FreeImage3110.zip and unzip it.  The Makefile that ships with FreeImage does not build correctly on OpenSolaris, so here is a Makefile that does -> http://blogs.sun.com/prashant/resource/files/Makefile.opensolaris  .

Change directory into the exploded FreeImage source, and utter the following.

gmake -f Makefile.opensolaris

gmake -f Makefile.opensolaris install

Where Makefile.opensolaris is the OpenSolaris Makefile that you just downloaded.

Step5:  The rbconfig.rb file in your Ruby installation needs to be changed.  Edit this file(it's to be found in /usr/ruby/1.8/lib/ruby/1.8/i386-solaris2.11 )

Look for a line that goes thus:

CONFIG["LDSHARED"] = "ld -G"

 and replace it with

CONFIG["LDSHARED"] = "$(CC) -G"

i.e., change the linker binary such that the GNU Linker is used by RubyInline(which is an ImageScience dependency).

This is a bug that will be fixed in build111.  So if you have a newer version, this bug might already have been fixed.

Step6: Now install ImageScience the usual way. 

gem install image_science


Step7: You should now be set.  But, just to make sure, run the ImageScience tests and make sure they pass.  Here is how to do that.

Edit $GEM_HOME/gems/image_science-1.1.3 test/test_image_science.rb (if you use the default gem home on OpenSolaris the file is to /var/ruby/1.8/gem_home/gems/image_science-1.1.3 test/test_image_science.rb ).

Add the following line to the beginning of the file.

 require 'rubygems'

Now test it by executing:

cd /var/ruby/1.8/gem_home/gems/image_science-1.1.3

(or cd $GEM_HOME/gems/image_science-1.1.3 if your gem home is different).

ruby test/test_image_science.rb

 Loaded suite test/test_image_science
Started
.......
Finished in 0.01314 seconds.

7 tests, 28 assertions, 0 failures, 0 errors

And thats all it takes to have a working ImageScience library.


Comments:

You're Makefile for FreeImage is using /usr as the install dir. This will not work in a zones environment. image_science by default looks for FreeImage in /opt/local - so it's good to simply set the installdir to this location.
See http://blogs.sun.com/shanti/entry/freeimage_and_imagescience_on_opensolaris

Posted by Shanti Subramanyam on March 26, 2009 at 04:47 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

prashant

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today