ImageScience

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. :)

Features:

Synopsis:

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

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

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

Requirements:

Installing:

  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 -d:pserver:anonymous@freeimage.cvs.sourceforge.net:/cvsroot/freeimage login
    # hit return at password prompt
    cvs -z3 -d:pserver:anonymous@freeimage.cvs.sourceforge.net:/cvsroot/freeimage 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

or:

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 libc++.so to the unversioned one... you know, the one everyone actually links to. You can usually fix it via:
    % sudo ln -s libc++.so.* libc++.so
in the appropriate directory.

For RedHat Enterprise Linux 4:

    make
    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.

Solaris

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

For (all?) other Platforms:

    make
    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.