FreeImage and ImageScience on OpenSolaris
Posted March 20, 2009on:
Although rails is a great development environment for web applications, for a newbie the deployment of a rails application can be challenging due to the myriad dependencies on various gems, native libraries etc.
image_science is one such ruby library that provides an easy way to generate thumbnails. It is therefore quite popular in web2.0 type applications (there isn’t a site today that doesn’t let you upload photographs of yourself, your pets, gadgets, whatever). It is a very simple implementation and available as a ruby gem and so easy to install. However, the real work is done by a native library called FreeImage and installing this on OpenSolaris is a little bit of work. Although, I use OpenSolaris here, the instructions apply to Solaris 10 as well if you are using ruby from Web Stack.
I found instructions from Joyent to build FreeImage on OpenSolaris but found them to be erroneous. To install FreeImage, do the following :
- Download the source from the repository using the command :
- Edit FreeImage/Makefile.solaris :
- Change INSTALLDIR to /opt/local
- Change all the lines for the install target as follows:
install -m 644 -u root -g root -f $(INSTALLDIR)/include Source/FreeImage.h
install -m 644 -u root -g root -f $(INSTALLDIR)/lib $(STATICLIB)
install -m 755 -u root -g root -f $(INSTALLDIR)/lib $(SHAREDLIB)
ln -sf $(INSTALLDIR)/lib/$(SHAREDLIB) $(INSTALLDIR)/lib/$(LIBNAME)
- Make all the install directories:
- Ensure you have gcc in your PATH (it’s in /usr/sfw/bin).
- Now we are ready to build the library:
cvs -z3 -d:pserver:firstname.lastname@example.org:/cvsroot/freeimage co -P FreeImage
mkdir -p /opt/local/lib /opt/local/include
gmake -f Makefile.solaris
gmake -f Makefile.solaris install
If everything went smoothly, you should see the following files in /opt/local:
# ls /opt/local/include
# ls -l /opt/local/lib
-rwxr-xr-x 1 root root 2978480 Mar 17 13:35 libfreeimage-3.12.0.so
-rw-r–r– 1 root root 3929756 Mar 17 13:35 libfreeimage.a
lrwxrwxrwx 1 root root 22 Mar 17 13:43 libfreeimage.so.3 -> libfreeimage-3.12.0.so
Now that we have FreeImage installed, installing ImageScience itself is real easy. But first, make sure you have the latest version of rubygems (1.3.1). The default rubygems in OpenSolaris 2008.11 is 0.9.4.
# gem –version
# bash-3.2# gem install rubygems-update
Bulk updating Gem source index for: http://gems.rubyforge.org
Successfully installed rubygems-update-1.3.1
This will print a lot of messages, but when it’s complete you should have rubygems 1.3.1.
# gem –version
We can now install the image_science gem. This will automatically install all dependent gems so the messages you see depends on what you have installed. On a OpenSolaris 2008.11 system you should see :
bash-3.2# gem install image_science
Successfully installed rubyforge-1.0.3
Successfully installed rake-0.8.4
Successfully installed hoe-1.11.0
Successfully installed ZenTest-4.0.0
Successfully installed RubyInline-3.8.1
Successfully installed image_science-1.1.3
6 gems installed
This will be followed by more messages indicating documentation for the above modules was also installed.
You are now ready to use image_science. Have fun !