Hate RMagic? Get Science! ImageScience!

ImageScience is a clean and happy Ruby library that generates thumbnails -- and kicks the living crap out of RMagick. Oh, and it doesn't leak memory like a sieve. :)



    ImageScience.with_image(file) do |img|
      img.cropped_thumbnail(100) do |thumb| "#{file}_cropped.png"

      img.thumbnail(100) do |thumb| "#{file}_thumb.png"

      img.resize(100, 150) do |img2| "#{file}_resize.png"



  1. Download and install FreeImage. See notes below.
  2. sudo gem install -y image_science

FreeImage Build Issues

Unfortunately there are minor issues with the makefiles in FreeImage. Until I get commit bits or get the issues resolved, I will try to keep detailed notes here. I'll keep updating them over time.

Getting Started:

    cvs -z3 login
    # hit return at password prompt
    cvs -z3 co -D 2007-01-01 -P FreeImage
    cd FreeImage

For Mac OS X / Darwin:

(you can now ignore getting started above if you have MacPorts)
    sudo port selfupdate
    sudo port install freeimage

NOTE: OSX builds a fat binary, so you need to have the 10.3.9 and 10.4 SDK's installed, preferably from xcode 2.3. They are in the "cross-compiling" section of the xcode install options.

NOTE: OSX needs to be using gcc 4.x:

    gcc_select 4.0
This mostly affects PPC / 10.4 users.

For 64-bit Systems:

Use 2007-02-11 instead of the date above on the cvs co. Especially if you see:

/usr/bin/ld: ./Source/FreeImage/BitmapAccess.o: relocation R_X86_64_32S against
`a local symbol' can not be used when making a shared object;
recompile with -fPIC


Source/Metadata/Exif.cpp:498: error: cast from 'BYTE*' to 'DWORD' loses precision
make[1]: *** [Source/Metadata/Exif.o] Error 1
Special Thanks to Matt Mower and Carmelyne.

For ubuntu/debian:

    aptitude install libfreeimage3 libfreeimage3-dev
If you see:
    /usr/bin/ld: cannot find -lstdc++
    collect2: ld returned 1 exit status
Then ubuntu/debian decided it was a good idea not to symlink the versioned to the unversioned one... you know, the one everyone actually links to. You can usually fix it via:
    % sudo ln -s*
in the appropriate directory.

For RedHat Enterprise Linux 4:

    PATH=$PATH:/usr/sbin sudo make install

Also, court3nay points out that the default SELinux setup will complain at runtime when image_science tries to load FreeImage. Try this suggestion to enable it.


Hugh notes that he had to change Source/FreeImage.h from #include <stdint.h> to #include <inttypes.h>.

For (all?) other Platforms:

    sudo make install

If that doesn't work, please file a bug and I'll try to help you figure it out and get some notes up here.